What is a NullReferenceException and how do I fix it?

preview_player
Показать описание
I have some code and when it executes, it throws a NullReferenceException, saying:

Object reference not set to an instance of an object.
What does this mean, and what can I do about it?
Рекомендации по теме
Комментарии
Автор

This NullReferenceException persistence had me ready to take a hammer to my computer. Then I listened to your video - this just pushed me over the edge!!
No I'm just kidding. Frustration makes me say funny things.

ajacobs
Автор

i understand every 5th word you are saying

ornnflakes
Автор

Can you please share the single line Syntex (3rd Method) to check null in VB#

BabaiDutta
Автор

If you want to fix NullReferenceException, try using List<String>, i show you as an exemple, i converted my code from VB .NET.


public string GetFileType(string extention)
{
List<string> szListType = new List<string>(new string[] { extention });
try
{
foreach (var szType in szListType)
return + + szType, "", szType), "", szType);
}
catch (Exception ex)
{
return _szType;
}
return null;
}

List<String> can avoid this annoying exception.

florin
Автор

hi very good explaination i have one issue in Filter class, while debugging same exception will come how i fix that one ?

lakshmikala
Автор

Object reference not set to an instance of an object.

ajayrautela
Автор

Don't speak. Your english is very bad.

deafandblind