473,803 Members | 3,616 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Whats the difference???

Hi all,

Can someone please give me a brief explaination how each of the following
differs?

long lVariable; //Variable name and type.

//How do the following methods differ???

1) (string)lVariab le;
2) Convert.ToStrin g(lVariable);
3) lVariable.ToStr ing();
4) GetString(lVari able);

Thank you.

--
Message posted via DotNetMonster.c om
http://www.dotnetmonster.com/Uwe/For...sharp/200511/1
Nov 17 '05 #1
3 1231
Hi Jon,
Can someone please give me a brief explaination how each of the following
differs?

long lVariable; //Variable name and type.
"long" is a type declaration. It defines the type of data the variable will
hold.
"1Variable" is an illegal variable name (you can't begin a variable name
with a number). A variable name is a reference to the data it holds. For
example, you are a person. Your name is "Jon." When I refer to you as "Jon"
I am not referring to your name, but to you. The same is true for variables.
Of course, variables must have unique names. If, for example, there were 2
Jons in the
room, I would have to use some modifier to specify which one I was referring
to. Variables don't have such modifiers, so the name must be unique within
the context of the scope that the variable exists in.
//How do the following methods differ???

1) (string)lVariab le;
Casting. This indicates that the variable should be cast (treated as) a
string. Casting and converting are different. Converting is the use of a
method to return an object of the new type. Casting is simply treating the
object temporarily as if it were of a different type. In the above
reference, no new object is created.
2) Convert.ToStrin g(lVariable);
This is an example of converting. The method returns a string, having a
string value of the variable.
3) lVariable.ToStr ing();
This is another conversion technique. It is simply a different method.
4) GetString(lVari able);
I'm not sure what this is. It is a method that returns a string, but you
didn't specify the class to which the method belongs. In any case, it is not
strictly a conversion, but a method that returns a string, which is somehow
derived from the variable. For example, a conversion can only return a
string representation of the object. A method can use the object and perform
any desired processing, to return a string, which may or may not be a string
represntation of the object.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition

"Jon S via DotNetMonster.c om" <u2272@uwe> wrote in message
news:5765efddbe 21d@uwe... Hi all,

Can someone please give me a brief explaination how each of the following
differs?

long lVariable; //Variable name and type.

//How do the following methods differ???

1) (string)lVariab le;
2) Convert.ToStrin g(lVariable);
3) lVariable.ToStr ing();
4) GetString(lVari able);

Thank you.

--
Message posted via DotNetMonster.c om
http://www.dotnetmonster.com/Uwe/For...sharp/200511/1

Nov 17 '05 #2
I need to correct myself. The "ToString() " method of an object is not
necessarily a conversion method. It depends on the particular object's
implementation of the method, which may or may not be overridden. Therefore,
the "ToString() " method is not a conversion method. Sorry.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition

"Jon S via DotNetMonster.c om" <u2272@uwe> wrote in message
news:5765efddbe 21d@uwe...
Hi all,

Can someone please give me a brief explaination how each of the following
differs?

long lVariable; //Variable name and type.

//How do the following methods differ???

1) (string)lVariab le;
2) Convert.ToStrin g(lVariable);
3) lVariable.ToStr ing();
4) GetString(lVari able);

Thank you.

--
Message posted via DotNetMonster.c om
http://www.dotnetmonster.com/Uwe/For...sharp/200511/1

Nov 17 '05 #3
No need apologise Kevin, you've helped me understand alot. Thank you.

--
Message posted via DotNetMonster.c om
http://www.dotnetmonster.com/Uwe/For...sharp/200511/1
Nov 17 '05 #4

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

Similar topics

2
2572
by: Showjumper | last post by:
Whats the diff between the 2 and when do you use one and not the other?
2
1836
by: Asha | last post by:
greetings, should i do this obj.dispose then obj = nothing both does the same thing right? whats the core difference?
3
19286
by: Amir Shitrit | last post by:
Hi to all. Whats the difference between DynamicInvoke and Invoke methods of the Delegate class? Thanks in advance.
2
2356
by: Ulrike Klusik | last post by:
Hello Folks, i've got two structural identical tables (including tablespace and indexes) with identical data, on which the access path of an SQL is differs. But I don't see a reason for the different behaviour. Both tables are allocated in the same database and storage space and use the same buffer pool. The DB2 subsystem is Version7.1 on z/OS. On both tables I've run REORG with standard statistics. I've checked for stale statistics...
2
5293
by: czi02 | last post by:
Hi there;; Im wondering whats the difference between vb to visual basic. net??? Does the program was different to visual basic than vb.net ???
4
2869
by: Uday Bidkar | last post by:
I am trying to register my interface with IConnectionPoint of outlook reminders to capture some Outlook Reminder events and having some issues. Here goes the pseudo code int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { //Register class CMyEventHandler : public IDispatch with
1
1996
by: yogesh | last post by:
i have a code as follows TServerDB() { fDB = Server()->dbStorage->Create(); } or fDB=TServer->TMySQLBD->Create(); can any one tell the relationship between two and whats the <between braces called
7
4447
by: Shafik | last post by:
Hello folks, I am an experienced programmer, but very new to python (2 days). I wanted to ask: what exactly is the difference between a tuple and a list? I'm sure there are some, but I can't seem to find a situation where I can use one but not the other. Thanks in advance, --Shafik
7
2277
by: Paulo | last post by:
Hi, what is diference between: File -New Web Site and File -New Project -VB/C# -Web Application ?????? VS 2005
2
2515
by: czi02 | last post by:
Whats the difference between vb6.0 and a vb.net? Does the same language has an crystal report ? How can I make an crystal report?
0
9703
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
9564
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
10548
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...
1
10295
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7604
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5500
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4275
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
2
3798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.