I have been looking at DbC lately and Spec# which seem to have support for non nullable objects. Unfortunately Spec# seem to have been abandoned.
Spec# seemed to have lots of nice language features built in so why was it abandoned?
Would there be any problem with letting all objects be non-nullable by default so you would have to write...
Hi again all,
I'm trying to pull some data from a SQL table in my dataset using C#.
In this case I do not need all the columns just a few specific ones, however as I am not pulling back a column with a mandatory NOT NULL, the copy of the table is throwing the exception
"Failed to enable constraints. One or more rows contain values...
I have a simple struct that has limited use. The struct is created in a method that calls the data from the database. If there is no data returned from the database I want to be able to return a null, but Visual Studio complains, Cannot convert null to PackageName.StructName because it is a non-nullable value type.
How can I make it nul...
I keep hearing people talk about how non-nullable reference types would solve so many bugs and make programming so much easier. Even the creator of null calls it his billion dollar mistake, and Spec# has introduced non-nullable types to combat this problem.
EDIT: Ignore my comment about Spec#. I misunderstood how it works.
EDIT 2: I m...
Why it is not allowed to assign null to a DateTime in C#? How has this been implemented? And can this feature be used to make your own classes non-nullable?
Example:
string stringTest = null; // Okay
DateTime dateTimeTest = null; // Compile error
I know that I can use DateTime? in C# 2.0 to allow null to be assigned to dateTimeTest a...
I'm designing a language, and I'm wondering if it's reasonable to make reference types non-nullable by default, and use "?" for nullable value and reference types. Are there any problems with this? What would you do about this:
class Foo {
Bar? b;
Bar b2;
Foo() {
b.DoSomething(); //valid, but will cause exception
...
I am writing algorithms that work on series of numeric data, where sometimes, a value in the series needs to be null. However, because this application is performance critical, I have avoided the use of nullable types. I have perf tested the algorithms to specifically compare the performance of using nullable types vs non-nullable type...
So far I've been using ISNULL(dbo.fn_GetPrice(ItemId), 0) to make it not nullable (rather call it default-valued, but whatever).
Is this the right way?
...
I've read many of the non-nullable questions and answers. It looks like the best way to get close to non-nullable types in C# (4.0) is Jon Skeet's NonNullable<> hack.
However, it seems that C++/CLI has solved much of the problem by supporting managed references: Foo% (instead of native C++ Foo&). The compiler makes this work by adding...
Just curious.
If you go:
string myString;
Its value is null.
But if you go:
int myInt;
What is the value of this variable in C#?
Thanks
David
...
I once read that having nullable types is an absolute evil. I believe it was in an article written by the very person who created them(in Ada?) I believe this is the article
Anyway, so what if by default a language like C# used non-nullable types? How would you replace some of the common idioms in C# or Ruby or any other common language...