Impact of Gen-AI on IT Jobs - Growth Mindset Show
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
.NET
ADO.NET
Android
ASP.NET
C#
Databases & DBA
Design Patterns & Practices
iOS
Java
OOP/OOD
SharePoint
Software Testing
Web Development
WPF
View All
2
Reply
Why can't we store null in value types?
Murali Poola
13y
6.9k
0
Reply
Delete Row
Delete Column
Insert Link
×
Insert
Cancel
Embed YouTube Video
×
Width (%)
Height (%)
Insert
Cancel
Table Options
×
Rows
Columns
First row as header
Create Table
Insert Image
×
Selected file:
Alignment
Left
Center
Right
Select an image from your device to upload
Upload to Server
Cancel
Submit
Variables that are based on value types directly contain values. Assigning one value type variable to another copies the contained value. This differs from the assignment of reference type variables, which copies a reference to the object but not the object itself. All value types are derived implicitly from the System.ValueType.Nullable
is a value type with a HasValue flag that can be false to indicate that there is no value. It still has a value (when HasValue is false, Value is default(T)), but the HasValue flag tells you to ignore the value. It has nothing to do with null, except that the CLR automatically unboxes null boxed values to a Nullable
with HasValue set to false.
Rajendra Tripathy
11y
0
A reference type is storeed as a reference (like a pointer) to an object instance. null means a reference that isn't pointing to an instance of an object. Value types are stored as the values themselves, without any references. Therefore, it doesn't make sense to have a null value type—the value type by definition contains a value.
Murali Poola
13y
0
What is the problem with Generic List being a return type?
Which is better, and when: using statement or calling Dispose() on an IDisposable in C#?
Message