Hi I was recently watching an old video about how null pointers were a billion dollar mistake. He points out both C# and java as they have run-time checks but don't completely eliminate it enough and this is somewhat understandable. He also points out the C at one point which he feels so sure of is a great problem. I get that null termin...
Looking at this line in the Settings.ttinclude
string CheckNullable(Column col){
string result="";
if(col.IsNullable && col.SysType !="byte[]" && col.SysType !="string")
result="?";
return result;
}
It describes how it determines if the column is nullable based on requirements and returns either "" or "?" to the ge...
Is this an idiomatic way to convert a Guid to a Guid??
new Guid?(new Guid(myString));
...
How can we implement a nullable type in C# if we didn't have this feature in C#?
...
a bool variable could hold true or false, while bool? could be null as well.
Why would we need a third value for bool ?
If it is not true, what ever it is, it is == false
Can you suggest a scenario where I would fancy a bool? instead.
Thanks
...
I want my C# program to know if the notNULL constraint is set for a specific Firebird database column. Can it be checked dynamically, perhaps by querying the meta data? I find the Firebird documentation to be very sparse.
Also, how does Firebird provide information what columns exist in a specific table?
...
Is this possible?
private void Test(out List<ExampleClass>? ExClass)
{
}
A nullable List<> that is also an out parameter?
...
The purpose is to enumerate the list and count how many nullable values I have, It will be used in order to test some Linq code because I lack of database. The thing is that no matter how I tried to define it I get from my compiler: "The type or namespace name List1' could not be found. Are you missing a using directive or an assembly ...
I use Nullable<T> types quite a lot when loading values into classes and structs when I need them to be nullable, such as loading a nullable value from a database (as the example below).
Consider this snippet of code:
public class InfoObject
{
public int? UserID { get; set; }
}
// Load the ID into an SqlInt32
SqlInt32 userID = rea...
How do you pronounce 'bool?', 'int?' and their ilk?
I've been mulling over options like "nullable of T", "T hook", "T huh", "T what" and "T" with a rising inflection.
I'm not particularly satisfied with these as they seem either cumbersome or affected or both.
...
Working with four tables.
Users -> has basic user info including a userid and a departmentid (int)
Groups -> basic group info including a groupid
GroupsMembers -> table that has the relationship between a group and it's members, many to many relationship, so groupid and userid are the columns
Departments -> basic department info includi...
I read with excitement the first article that popped up in google -- it was exactly my problem. I have an object model with a non-null date field, but the underlying database field was nullable, and had a null value. It was a DateTime. nHibernate set the value to .Net's Date.MinValue, then tried to save it back, yielding an error.
Th...
I am reading an article about the MVVP Pattern and how to implement it with WPF. In the source code there are multiple lines where I cannot figure out what the question marks in it stand for.
private DateTime? _value;
What does the ? mean in the definition? I tried to find it in the help from VS but failed.
...
I'm trying to create a view where I want a column to be only true or false. However, it seems that no matter what I do, SQL Server (2008) believes my bit column can somehow be null.
I have a table called "Product" with the column "Status" which is INT, NULL. In a view, I want to return a row for each row in Product, with a BIT column se...
Hey All,
I have:
Class Foo
{
String name;
String value;
Foo parent; //Foo.parent is OneToOne and nullable
}
I have the following HQL:
FROM Foo f WHERE
(lower(f.name) like concat( lower('string') , '%' )) or
(lower(f.value) like concat( lower('string') , '%' )) or
(lower(f.parent.name) like concat( lower('string') , '%' ))
The que...
trait NotNull {}
I've been trying to see how this trait can guarantee that something is not null and I can't figure it out:
def main(args: Array[String]) {
val i = List(1, 2)
foo(i) //(*)
}
def foo(a: Any) = println(a.hashCode)
def foo(@NotNull a: Any) = println(a.hashCode) //compile error: trait NotNull is abstract
def foo(a:...
I've tried two ways to constrain a generic type parameter to a nullable type, but both seem to have some unexpected problems.
First attempt (using T <: AnyRef):
scala> def testAnyRefConstraint[T <: AnyRef](option:Option[T]):T = {
| //without the cast, fails with compiler error:
| // "found: Null(null) required: T"
| o...
I have a few places where I need to compare 2 (nullable) values, to see if they're the same.
I think there should be something in the framework to support this, but can't find anything, so instead have the following:
public static bool IsDifferentTo(this bool? x, bool? y)
{
return (x.HasValue != y.HasValue) ? true : x.HasValue && x...
Which approach is recommended:
void Add(int? value)
{
command.Parameters.Add("@foo").Value = value;
}
or
void Add(int? value)
{
command.Parameters.Add("@foo").Value = (object)value ?? DBNull.Value;
}
...
I'm currently working with a library and noticed something weird when using functions I already made(where I must do casting).
The library had a function defined like
public DateTime? GetDate(){..}
What is the point of this? Why not just make it a regular DateTime and return null as normal if there is some error getting the date? Am...