Top "Value-type" questions

In computer science, the term value type is commonly used to refer to one of two kinds of data types: Types of values or Types of objects with deep copy semantics.

Why are delegates reference types?

Quick note on the accepted answer: I disagree with a small part of Jeffrey's answer, namely the point that since …

c# .net delegates value-type reference-type
Indexers in List vs Array

How are the Indexers are defined in List and Arrays. List<MyStruct> lists=new List<MyStruct>(); …

c# value-type
Why String is Value type although it is a class not a struct?

Take the following example: string me = "Ibraheem"; string copy = me; me = "Empty"; Console.WriteLine(me); Console.WriteLine(copy); The output …

c# string types reference value-type
In C# , Are Value types mutable or immutable ?

Value types behavior shows that whatever value we are holding cannot be changed through some other variable . But I still …

c# value-type reference-type
Are value types immutable by definition?

I frequently read that structs should be immutable - aren't they by definition? Do you consider int to be immutable? …

c# .net immutability value-type
Detailed Explanation of Variable Capture in Closures

I've seen countless posts on how variable capture pulls in variables for the creation of the closure, however they all …

c# .net closures value-type reference-type
Is creating a C# generic method that accepts (nullable) value type and reference type possible?

I want to create a simple method that accepts both value type and reference type parameters, i.e. int is …

c# .net generics value-type reference-type
Local variable (int) might not be initialized before accessing

I have the following method defined in a class: public bool LogOff(string sessionId) { int res; // Some non related code …

c# value-type
.NET Parameter passing - by reference v/s by value

I'm trying to validate my understanding of how C#/.NET/CLR treats value types and reference types. I've read so …

c# .net clr value-type reference-type
Pattern for Creating a Simple and Efficient Value type

Motivation: In reading Mark Seemann’s blog on Code Smell: Automatic Property he says near the end: The bottom line …

c# design-patterns encapsulation value-type solid-principles