Linked Questions

5 votes
4 answers
7k views

Possible Duplicate: Structure Vs Class in C# Sorry if this is a open ended question, but I just want to know if my struct is too big. The reason why i want to use a struct is because I've learned ...
Bigfatty's user avatar
  • 159
0 votes
2 answers
1k views

So I have this: class SimpleDateStructureDemo { struct Date { public int year; public int month; public int day; } static void Main() { ... } } And then I see an ...
user997578's user avatar
342 votes
16 answers
126k views

MSDN says that you should use structs when you need lightweight objects. Are there any other scenarios when a struct is preferable over a class? Some people might have forgotten that: structs can ...
Esteban Araya's user avatar
309 votes
13 answers
154k views

In .NET, a value type (C# struct) can't have a constructor with no parameters. According to this post this is mandated by the CLI specification. What happens is that for every value-type a default ...
Motti's user avatar
  • 116k
59 votes
17 answers
26k views

Please help us settle the controversy of "Nearly" everything is an object (an answer to Stack Overflow question As a novice, is there anything I should beware of before learning C#?). I thought that ...
missaghi's user avatar
  • 5,110
64 votes
6 answers
47k views

Are there some good resources for fixed point math in C#? I've seen things like this (http://2ddev.72dpiarmy.com/viewtopic.php?id=156) and this (What's the best way to do fixed-point math?), and a ...
Chris McElligott Park's user avatar
24 votes
3 answers
61k views

Possible Duplicate: Which is best for data store Struct/Classes? Consider the example where I have an Employee object with attributes like age, name, gender, title, salary. I now have a list i ...
AMH's user avatar
  • 6,471
54 votes
3 answers
4k views

In C# setting a value to a variable is atomic as long as its size is at most native int (i.e. 4 bytes in a 32-bit runtime environment and 8 bytes on a 64-bit one). In a 64-bit environment that ...
i3arnon's user avatar
  • 117k
29 votes
1 answer
10k views

My understanding is that Parameterless constructors in structs are now allowed. But the following gives me a compile error in VS 2015 Community public struct Person { public string Name { get; ...
myfunnyfella's user avatar
  • 1,487
22 votes
4 answers
8k views

Is there any sense in defining a struct with a reference type member (and not defining it as a class)? For example, to define this struct: public struct SomeStruct { string name; Int32 place;...
Yanshof's user avatar
  • 9,955
12 votes
5 answers
3k views

When operator new() is used with reference type, space for the instance is allocated on the heap and reference variable itself is placed on the stack. Besides that, everything within the instance of ...
dragan.stepanovic's user avatar
17 votes
2 answers
13k views

Int has a size of 4 bytes, if I create a new Int in my program will incresse its memory consumption by 4 bytes. Right? But if I have this class public class Dummy{ private int; } How much memory ...
Simon Edström's user avatar
18 votes
5 answers
1k views

public struct Test { public double Val; public Test(double val = double.NaN) { Val = val; } public bool IsValid { get { return !double.IsNaN(Val); } } } Test myTest = new Test(); bool ...
Ricibob's user avatar
  • 7,755
6 votes
1 answer
4k views

struct vvvv { public int j = 8; //public vvvv() { } error } class cccc { public int f = 8; } In the struct if I comment out the constructor the compiler tells me that the field j ...
Erik_JI's user avatar
  • 315
4 votes
3 answers
929 views

If I execute the following statement: dim defaultDate as Date = Nothing defaultDate contains the default value of the Date structure I suspect there is a clean way to retreive this value, like some ...
Samuel Rossille's user avatar

15 30 50 per page