Linked Questions

45 votes
12 answers
36k views

I have a method with an out parameter that tries to do a type conversion. Basically: public void GetParameterValue(out object destination) { object paramVal = "I want to return this. could be any ...
CodingWithSpike's user avatar
2 votes
1 answer
187 views

I have created a test code snippet demonstrating what I am trying to achieve. But it does not work as expected (see comments in code): public class Program { public static void Main() { ...
Alexander Abakumov's user avatar
6 votes
6 answers
2k views

Is it possible to test if a variable is defined as a string if the value inside it is null? If I write: string b = null; bool c = b is string; Then c will be false because is looks at the content, ...
Ohlin's user avatar
  • 4,208
6 votes
2 answers
8k views

I was looking into nullable bools when I found this article on Microsoft MSDN How to: Identify a Nullable Type (C# Programming Guide) You can use the C# typeof operator to create a Type object that ...
Daniel's user avatar
  • 11.3k
9 votes
2 answers
665 views

If an object is initialized to null, it is not possible to get the type information because the reference doesn't point to anything. However, when I debug and I hover over a variable, it shows the ...
Abel's user avatar
  • 57.5k
0 votes
3 answers
2k views

How do I find out the type of a View's Model within the View itself? I tried doing calling GetType: @model MyModel <div>@Model.GetType()</div> which works unless the Model is null, in ...
dav_i's user avatar
  • 28.2k
0 votes
3 answers
271 views

Is there any way to get a type of the null value? This does not work: let a: string = null let typ = a.GetType() Thanks
Oldrich Svec's user avatar
  • 4,231
-1 votes
2 answers
2k views

There is main a variable which has uninitialized variables. I need to retrieve the Type of uninitialized varible type with reflection. Because I am generating the values dynamically but can't get the ...
uzay95's user avatar
  • 16.8k
1 vote
4 answers
433 views

The MSDN documentation for the is keyword says: expression is not null Why? If MethodThatReturnsNull() is type were called shouldn't that return false since null certainly isn't that type?
jasonh's user avatar
  • 30.4k
0 votes
4 answers
204 views

protected static SqlParameter CreateParameter(string name, object value, bool skipEmpty, bool isOutput =false) { if (skipEmpty && value is string && string.IsNullOrEmpty((string)...
Alexandre's user avatar
  • 13.3k
1 vote
0 answers
532 views

I'm using reflection to call a static, generic method (as the type is only known at runtime). This seems to be working well for me, until the type is of string. I get an "Object not set to an instance ...
James D's user avatar
  • 400
2 votes
1 answer
262 views

Question Why is $null + @{} valid, but @{} + $null not; even where null is cast to a hashtable (@{} + ([hashtable]$null)). Example Code [hashtable]$a = @{demo1=1;demo2='two'} [hashtable]$b = @{...
JohnLBevan's user avatar
  • 24.8k