Page 1 of 1
Can two objects have same name?
Posted: Wed Jan 21, 2015 3:35 pm
by Ya-hoo
iX allows two objects linked to same tag. Can two objects have same name?
Re: Can two objects have same name?
Posted: Thu Mar 26, 2015 3:59 am
by mwidger
Ya-Hoo,
I would not advise it as objects should be uniquely identifiable. The .Net framework will also complain if the object types are the same and you use the same name (although this depends on object scope - see below).
So you could have the following which will be OK (but is poor practice) as the object types are different but the name is the same.
string myVar;
int myVar;
But having 2 strings defined in the project with the same name is just asking for trouble and should be avoided (again this really depends on scope).
string myVar;
string myVar; - not allowed in .Net as the variable myVar is already defined
This applies to objects used in scripts and those that you have dragged and dropped onto the form designer.
It may be worthwhile reading up on variable scope within the .Net framework
https://msdn.microsoft.com/en-us/library/ms973875.aspx
as this explains variable and method scope very well.
Hope this helps,