c# - Combo Box selected Item gives Exception -
i have combobox following items:
1024 2048 4096 8192
i using following code retrive item selected user:
string cach = form.combocache.selecteditem.tostring();
but line giving exception null reference exception, object reference not set instance of object
if line giving nullreferenceexception
1 of following true:
form
nullform.combocache
nullform.combocache.selecteditem
null
either reason code work out of case, or put breakpoint on line , debug it, @ form
in watch window.
once you've worked out part null, need step , work out why it's null - because presumably expecting not null. don't have enough context here work out (we don't know kind of app you're writing - web, winforms etc) - it'll obvious debugger.
Comments
Post a Comment