that and 1000 other improvements in the hugely underrated vb.net makes me use it. plus, it makes my usefull screen solution even insaner.
i mean.. i have a class
Class
'in this class i have a class and an instance of it
dim test as test 'this word is already used
class test
end class
end class
We had no idea you were using VB from your OP. camelCasing is something you can do in C#, not VB (unless that's been added). VB is not case-sensitive so "this" is the same as "This" as far as it's concerned.
Mark all posts that give the desired result the answer. If you only mark the last that gave you clarification because you misread an earlier post others will be confused. Some of us are here to help others and our point to post ratio matters.
that and 1000 other improvements in the hugely underrated vb.net makes me use it. plus, it makes my usefull screen solution even insaner.
i mean.. i have a class
Class
'in this class i have a class and an instance of it
dim test as test 'this word is already used
class test
end class
end class
It is certainly possible to have a Floor class and create an instance of Floor pointed to by a variable name floor.
Public Class Floor
Public Overrides Function ToString() As String
Return "Hey, from Floor!"
End Function
End Class
Implementation
Sub Main()
Dim floor As New Floor()
Console.WriteLine(floor.ToString())
End Sub
Result
Hey, from Floor!
If you are trying to create an Instance of Floor within floor that is also possible.
Public Class Floor
Dim floor As Floor
Public Function FlootMemberToString() As String
floor = New Floor
Return "FlootMemberToString -> " & Me.floor.ToString()
End Function
Public Overrides Function ToString() As String
Return "Hey, from Floor!"
End Function
End Class
An older local member naming convention is m_floor but this has been simplified to
_floor over time. You'll see the underscore in C# too.
Public Class Floor
Dim _floor As Floor
Public Function FlootMemberToString() As String
_floor = New Floor
Return "FlootMemberToString -> " & _floor.ToString()
End Function
Public Overrides Function ToString() As String
Return "Hey, from Floor!"
End Function
End Class
VB naming converntions have been around a long time and are well documented. Start by reading the VB.NET programming guide.
Member
7 Points
236 Posts
best naming practise for class objects
Feb 02, 2018 06:53 PM|uid390594|LINK
hi..
i have a class FloorType (which describes properties for a Type of Floor (such as grass, street, etc)
in the same class as where the FloorType class is, i want to create an instance of this class. but i cant use the same name because its already used.
what is the best naming practise in this scenario?
Nameing the Class FloorTypeClass and the object FloorType, seems a bit uncomfy.
Member
68 Points
240 Posts
Re: best naming practise for class objects
Feb 02, 2018 08:09 PM|vinodkpasi|LINK
You can use camel-casing.
FloorType floorType =new FloorType();
You can also use "this" keyword to refer object of current class or directly you can use class member in same class.
Member
7 Points
236 Posts
Re: best naming practise for class objects
Feb 02, 2018 09:40 PM|uid390594|LINK
that is the worst practise ever.
that and 1000 other improvements in the hugely underrated vb.net makes me use it. plus, it makes my usefull screen solution even insaner.
i mean.. i have a class
Class
'in this class i have a class and an instance of it
dim test as test 'this word is already used
class test
end class
end class
Contributor
7048 Points
2187 Posts
Re: best naming practise for class objects
Feb 02, 2018 09:48 PM|ryanbesko|LINK
All-Star
52221 Points
23292 Posts
Re: best naming practise for class objects
Feb 02, 2018 10:29 PM|mgebhard|LINK
It is certainly possible to have a Floor class and create an instance of Floor pointed to by a variable name floor.
Implementation
Result
If you are trying to create an Instance of Floor within floor that is also possible.
An older local member naming convention is m_floor but this has been simplified to _floor over time. You'll see the underscore in C# too.
VB naming converntions have been around a long time and are well documented. Start by reading the VB.NET programming guide.
https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/program-structure/naming-conventions
Coding conventions
https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/program-structure/coding-conventions
Older naming converntions that still common.
https://msdn.microsoft.com/en-us/library/aa263493(v=vs.60).aspx
All-Star
191723 Points
20951 Posts
ASPInsiders
Moderator
MVP
Re: best naming practise for class objects
Feb 19, 2018 09:49 AM|XIII|LINK
Hi,
Actually the C# alternative for this in VB.NET is Me.
Kris.
Working with Azure, chatbots, ASP.NET MVC, Web API, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!