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
...
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...
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())
{
...
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 the difference between a DateTime? and a DateTime (without a question mark) in C#?
...
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...
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?
...
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 ...
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
{
...
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 ...
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...
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.
...
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...
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...
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 ...
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 ...
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.
...
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?
...
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...
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....