Linked Questions
12 questions linked to/from How to get the lowercase name of an object, even when null, in C#
45
votes
12
answers
36k
views
.NET : How do you get the Type of a null object?
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 ...
2
votes
1
answer
187
views
How to distinct between (object)null and (decimal?)null when passed in object parameter? [duplicate]
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()
{
...
6
votes
6
answers
2k
views
How to test a null value variable if it's a string?
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, ...
6
votes
2
answers
8k
views
GetType on Nullable Boolean
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 ...
9
votes
2
answers
665
views
How does the debugger get type information about an object initialized to null?
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 ...
0
votes
3
answers
2k
views
How to get the Model type in a view
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 ...
0
votes
3
answers
271
views
Type of the null value using F#
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
-1
votes
2
answers
2k
views
Getting type of not initialized variable
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 ...
1
vote
4
answers
433
views
Why does the is keyword require a non-null expression?
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?
0
votes
4
answers
204
views
Nullable types in .NET
protected static SqlParameter CreateParameter(string name, object value, bool skipEmpty, bool isOutput =false)
{
if (skipEmpty && value is string && string.IsNullOrEmpty((string)...
1
vote
0
answers
532
views
GetType() of an empty string variable
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 ...
2
votes
1
answer
262
views
Behaviour of PowerShell when Combining HashTables
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 = @{...