Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert an Integer? to an Integer in VB.NET?

Tags:

vb.net

I'm a C# programmer but am converting some code from C# to VB.NET. In c# I can simply use (int)blah.getValue() where getValue() returns an Integer?

Doing a DirectCast() in VB.NET doesn't work though, saying Integer? cannot be converted to Integer.

Ideas?

like image 522
NibblyPig Avatar asked Feb 09 '10 11:02

NibblyPig


1 Answers

Use the value property to get the actual integer value.

Dim intNullable As Integer?

If intNullable.HasValue Then
 Return intNullable.Value
End If
like image 169
Rhapsody Avatar answered Sep 21 '22 17:09

Rhapsody