473,624 Members | 2,252 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I determine the name of a new object or variable at run-ti

Hi!
I want to write C# code by which I can determine the name of an object
and/or variable at run-time.

VS design windows does it when you drag a control onto your form. It uses
the name of the control's type and adds a number to it and creates a name for
the object, like "button2".

Regards
M Shafaat

Nov 17 '05 #1
3 1162
Do you mean the name of the type of the object? objects don't have names

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

Hi!
I want to write C# code by which I can determine the name of an object
and/or variable at run-time.

VS design windows does it when you drag a control onto your form. It uses
the name of the control's type and adds a number to it and creates a name for
the object, like "button2".

Regards
M Shafaat

Nov 17 '05 #2
Hi,

If the object is derived from Control ( like textbox, combobox, etc ) you
can use Control.Name ,

what is what you want to do anyway?

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"M Shafaat" <M Sh*****@discuss ions.microsoft. com> wrote in message
news:5E******** *************** ***********@mic rosoft.com...
Hi!
I want to write C# code by which I can determine the name of an object
and/or variable at run-time.

VS design windows does it when you drag a control onto your form. It uses
the name of the control's type and adds a number to it and creates a name
for
the object, like "button2".

Regards
M Shafaat

Nov 17 '05 #3
Well, sorry I expressed badly what I want to do.
By "name", I mean "identifier ".

Regards
M Shafaat

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

If the object is derived from Control ( like textbox, combobox, etc ) you
can use Control.Name ,

what is what you want to do anyway?

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"M Shafaat" <M Sh*****@discuss ions.microsoft. com> wrote in message
news:5E******** *************** ***********@mic rosoft.com...
Hi!
I want to write C# code by which I can determine the name of an object
and/or variable at run-time.

VS design windows does it when you drag a control onto your form. It uses
the name of the control's type and adds a number to it and creates a name
for
the object, like "button2".

Regards
M Shafaat


Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3837
by: Mark Fisher | last post by:
I have a Java desktop GUI application that the user can run multiple times. In order to keep one instance of the application distinct from another, I'd like to put the instance number of the application in the title bar. For example, the user starts the application, and the title bar says "Control Panel". The user starts another instance of the application, and it knows that one instance is already running, so the title bar of the...
18
2876
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code that applies to all these events, but I need to have specific code execute when the form closes. The properties for this method are sender (the originator) and e (event arguments). I know how to get typeof (sender) to determine what form or...
3
1690
by: mikeorb | last post by:
Is there a way to determine the object that a property is in? For example: function MyClass() { ... } MyClass.prototype.myFunc = function() { ... } var obj = new MyClass(); var sameobj = SOMEFUNCTION(obj.myFunc); So my goal is to get a reference to the object by just having the
10
1452
by: Lance | last post by:
Is there any way to determine the full name of an object at runtime? For example, if I have the following Namespace MyNameSpac Public Class MyClas Protected MyObject As Object 'This could be any type End Clas End Namespac then I want a function that would return the string, "RootNamespace.MyNameSpace.MyClass.MyObject" if I passed MyObject to the function, where RootNamespace is the root namespace for the project
7
14142
by: Doru Roman | last post by:
Hi, What is the fastest way to evaluate manually the result in this case: int a, b, c; a = 255; b = 122; c = a & b; The only way I know is transforming each number into the binary value and
5
6838
by: MLH | last post by:
Suppose MyName, a string variable equals "frmEnterClients". How can I determine ... 1) if frmEnterClients exists as an object in the database? 2) what type of object is it (tbl, qry, frm, rpt, mac, mod)?
3
11572
by: Developer in California | last post by:
I am working on developing a generic Web framework using Master Pages in ASP.NET 2.0. What I have done is created a PageRenderer class which has a public method which will retrieve the path of the content I want to execute based on the name of the asp:Content control. As shown in the code snippet below, to get the content I want to display, I call the GetContentPagePath public method in PageRenderer passing a string duplicating the value...
8
1699
by: Ole | last post by:
If I define a class and create a instant of it like e.g.: UserClass instantName = new UserClass(); how do I then determine the defined name "instantName" in the UserClass e.g. in a method (or a property) like this: public void userFunction() { string Var = new string();
13
3819
by: softwaredoug | last post by:
I can't see to easily find this on google or in a newsgroup Is there a standard function/macro/whatever you can call and determine the distance in a C program how deep one is in the C call stack from main. Something along the lines: int main() {
0
8242
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8177
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8681
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8629
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7170
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4183
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1793
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1488
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.