OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to declare a fixed length string type within a record in C#?

  • Thread starter Thread starter Mario
  • Start date Start date
M

Mario

Guest
I'm trying to create a record type in C# with some fields as fixed length strings.

I just want to use this record for further reading of a predefined file format.

I tried this:

Code:
  public record Person (int  age, fixed char  birthdate[8]);

However, I'm getting the following error

Array size cannot be specified in a variable declaration (try initializing with a 'new' expression)CS0270

I'm using the Visual Studio Code Version: 1.88.1 (Universal).

Can you help me?

Thanks in advance, Mario
<p>I'm trying to create a record type in C# with some fields as fixed length strings.</p>
<p>I just want to use this record for further reading of a predefined file format.</p>
<p>I tried this:</p>
<pre><code> public record Person (int age, fixed char birthdate[8]);
</code></pre>
<p>However, I'm getting the following error</p>
<p>Array size cannot be specified in a variable declaration (try initializing with a 'new' expression)CS0270</p>
<p>I'm using the Visual Studio Code Version: 1.88.1 (Universal).</p>
<p>Can you help me?</p>
<p>Thanks in advance,
Mario</p>
Continue reading...
 

Latest posts

D
Replies
0
Views
1
Domantas Giedraitis
D
Top