All Questions
Tagged with value-type vb.net
15
questions
0
votes
1
answer
1k
views
Check for null value for value types in VB.NET
I have a KeyValuePair(Of TKey,TValue) and I want to check if it is null or not:
Dim dictionary = new Dictionary(Of Tkey,TValue)
Dim keyValuePair = dictionary.FirstOrDefault(Function(item) item.Key = *...
0
votes
0
answers
192
views
Visual Basic: IsNothing() function with Guid values
I bumped into the following legacy VB code (customerId is Guid):
If IsNothing(customerID) Or (customerID.Equals(System.Guid.Empty)) Then
Throw New InvalidCustomerException
End If
According this ...
0
votes
0
answers
239
views
VB.NET If statement does something strange with Nullable Enum Type
I just ran into the following behavior that's so strange that I can't figure out how it could be correct.
Suppose I have an Enum like;
Enum MyEnum
...
End Enum
and a routine that returns a ...
0
votes
1
answer
238
views
If string is reference type, why pass by reference is not happening?
I had read an article http://www.albahari.com/valuevsreftypes.aspx
As per this, int is a value type and form is an example of reference type.
Point myPoint = new Point (0, 0); // a new value-...
-2
votes
1
answer
82
views
Vb.net/C# make classes store value types
I need to declare a class whose properties are stored as value types. I also need to make my class inheritable, so I can't make it a structure.
Class MyClass
...
End Class
Class InheritingClass
...
1
vote
1
answer
2k
views
Datagridview valuetype property not changing
I have some code to convert the datatypes of some of the columns of a datagridview into a double, as they should be displaying as currency in my grid view.
However when I run the code, the values are ...
7
votes
3
answers
6k
views
DateTime in VB.NET and C#
I have two questions:
Date and DateTime : Are they different or same in VB ?
DateTime can be assigned Nothing in VB, where as it cannot be assigned null in C#. Being a structure it cannot be null. So ...
0
votes
4
answers
151
views
Equals(...) does not return the same after boxing
See the following code:
Private Function EqualsNothing(ByVal item As Object) As Boolean
Return item.Equals(Nothing)
End Function
Console.WriteLine(0.Equals(Nothing)) ' True
Console.WriteLine(...
1
vote
1
answer
137
views
Can't Set 'Value' of a custom ValueType
I have created a custom ValueType:
Private Structure MyValueType
Private _integerValue As Integer
Public Sub New(initValue As Integer)
_integerValue = initValue
End Sub
...
7
votes
3
answers
734
views
Are all objects that don't inherit from System.ValueType reference type?
Am I correct in believing that any object that doesn't inherit from System.ValueType must therefore by definition be a reference type?
I've been unable to find any conclusive documentation to backup ...
10
votes
3
answers
63k
views
VB Check if int is empty
A really boring question, sorry, but I really don't know that yet ;) I've tried always string.empty, but with a decimal this produces an error.
Is there any function? Unfortunately, for the simplest ...
0
votes
1
answer
620
views
VB.NET Pointer to value types
VB.NET 2010, .NET 4
Hello all,
I'm by no means a good programmer and I'm just trying to wrap my head around some of this stuff, so please forgive me if this is a dumb question.
I want the following ...
1
vote
2
answers
57
views
Is this some kind of referencing problem? Value not sticking
Apologies for the appalling title.
I have mocked up this code to mimic an issue I was encountering on a project.
I want to know why the property status does not 'stick'. Stepping through the code I ...
0
votes
1
answer
830
views
Can I define an assignment operator in vb.net Structure?
I am having a structure that is actually a simple byte with more functionality.
I defined it this way:
Structure DeltaTime
Private m_DeltaTime As Byte
Public ReadOnly DeltaTime As Byte
...
3
votes
3
answers
239
views
Is there a difference between declaring and constructing a value type object?
I've been working in .NET for some time now, but occasionally I still get confused by a disparity between the framework and my prior experience in C++.
In .NET, all objects are either value types or ...