nullable

Creating Nullables types in java

I am trying to create a nullalble object in Java but no idea how to do this , in C# this would be done like this int? someTestInt; This allows me to check for for null , while in certain cases i can use a 0 value ,this isnt always possible since certain execution paths allow 0 values ...

Best alternative for .NET nullable value type for Java-consumable service

We are creating some WCF services that will initially be consumed by .NET clients but in the future will be consumed to Java clients. As such we want to avoid using any data types in the interface that Java does not support. The specific one we know of is nullable value types. One suggestion is that we can support these by using a str...

C# determine a Nullable property DateTime type when using reflection

Hi, I have a question on how to determine an object's Nullable property type. ObjectA with a property DateTime? CreateDate; when i am iterate through it's properties like the following code, how do I check if a property is a Nullable DateTime type? thanks foreach (PropertyInfo pi in ObjectA.GetType().GetProperties()) { ...

C# newbie: what's the difference between "bool" and "bool?" ?

Hello, I'm starting with C#, and encountered something that puzzles me. I use the "bool" type for variables as I was used to in C++, and I try to put the values of functions or properties I expect to be boolean into my variable. However often I encounter cases where the result type is "bool?" and not "bool" and the implicit casting fail...

What is a "DateTime?" as opposed to just a DateTime in C#?

What is the difference between a DateTime? and a DateTime (without a question mark) in C#? ...

How do I obtain information about a nullable foreign key from Information_Schema views?

I'm using the INFORMATION_SCHEMA views in Sql Server 2005 & 2008 to obtain metadata for a database: SELECT PK.TABLE_NAME as 'PK_TABLE_NAME', FK.TABLE_NAME as 'FK_TABLE_NAME', C.CONSTRAINT_NAME as 'CONSTRAINT_NAME' FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS C JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS FK ON C.CONS...

Nullable variable types - .value member

Hello, I was wondering - when would I want to use the .Value member on a nullable type instead of just calling the variable itself? e.g.. bool? b = true; why would i use b.Value to get the value instead of just using b? What advantage or function does the .Value call add? ...

Is there such a thing as a nullable bool in vb.net

I am working through my new MVC book and of course, the samples are all in c# as usual. There is a line of code that says public bool? WillAttend { get; set; } The author explains that the question mark indicates that this is a nullable (tri-state) bool that can be true, false. or null. (A new C# 3 convention.) Does vb.net support ...

Do I have to do validation on a property of type Nullable<int>?

I'm creating a custom configuration section (inheriting System.Configuration.ConfigurationSection), and I'm wondering if I have to do value validation for a ConfigurationProperty that is a Nullable int. I.e., do I have to do this: [ConfigurationProperty("NullableInt", IsRequired = true)] public int? NullableInt { get { ...

VB.NET 3.5; compiler complaining about nullable types (as in Double?) with "error BC30037: Character is not valid."

So, Visual studio just started throwing "error BC30037: Character is not valid." at me (while validating a web site) whenever I use the nullable operator anywhere within one of my VB.NET 3.5 projects. This happened to a colleague some months ago but he doesn't remember how he fixed (I seem to remember it fixing itself eventually). If ...

Is there a better way to write this line of C# code in C#3.0?

I have a property declared as follows: public decimal? MyProperty { get; set; } I am needing to pass this value to another method as a string and so the only way I see to do so is as follows: MyProperty == null ? null : MyProperty.ToString() This looks very messy when you have a number of similar properties being passed into a meth...

Cannot see members of a structure declared as nullable

In VB.NET, why can't I see a member of a structure when I make it a nullable type? Example: Public Structure myNullable Dim myNullVar As Integer End Structure Sub Main() Dim myInstance As myNullable 'This works. Dim myNullableInstance? As myNullable 'This works. myInstance.myNullVar = 1 'This works. ...

C# code wont compile. No implicit conversion between null and int

Possible Duplicate: Nullable types and the ternary operator. Why wont this work? Why doesn't this work? Seems like valid code. Can anyone help? string cert = ddCovCert.SelectedValue; int? x = (string.IsNullOrEmpty(cert)) ? null: int.Parse(cert); Display(x); How should I code this? The method takes a Nullable. If the dro...

What is the correct way to serialize nullable types?

I'm implementing IXMLSerializable in one of my classes. It contains a few numeric properties that are nullable (int? double? etc..) What is the correct way to serialize/serialize these through IXMLSerializable? Here's what I'm doing now, which works, but obviously does not seem like the correct way to do it. void IXmlSerializable.Write...

Deserializing empty xml attribute value into nullable int property using XmlSerializer

Hello, I get an xml from the 3rd party and I need to deserialize it into C# object. This xml may contain attributes with value of integer type or empty value: attr=”11” or attr=””. I want to deserialize this attribute value into the property with type of nullable integer. But XmlSerializer does not support deserialization into nullable ...

MySQL ON DUPLICATE KEY UPDATE with nullable column in unique key

Our MySQL web analytics database contains a summary table which is updated throughout the day as new activity is imported. We use ON DUPLICATE KEY UPDATE in order that the summarization overwrites earlier calculations, but are having difficulty because one of the columns in the summary table's UNIQUE KEY is an optional FK, and contains ...

Can I make an embedded Hibernate entity non-nullable?

What I want: @Embedded(nullable = false) private Direito direito; However, as you know there's no such attribute to @Embeddable. Is there a correct way to do this? I don't want workarounds. ...

System.Nullable<T> What is the value of null * int value?

Consider the following statements: int? v1 = null; int? v2 = 5 * v1; What is the value of v2? (null or empty string?) How can I prevent the compiler to mark it as invalid operation? Do I need to follow custom exception handling? ...

Type Inference in Extension Method

I'm sure this has been asked before, but my perusal of the search hits for similar questions did not yield an answer. I am tired of checking if Nullable has a value. Why can't I assign myNullable<int> yourAge to int myAge and get an exception if yourAge is null? Furthermore, if either of our damned ages is null, why do I have to do a...

Asp.net Mvc: Filters nullable parameter

Hello, I am trying to use a nullable datetime and double as a parameter for an actionfilter but it's gives the following error: 'Propertyname' is not a valid named attribute argument because it is not a valid attribute parameter type I thought a quick google would solve it but to my surpise I couldn't find a lot of info about it....