|
Hi all,
I have tested using ref in passing reference to method,
e.g.
Car car1 = new Car();
Change(ref car);
...
void Change(ref Car car)
{
car.id = 1;
//car = null;
//car = new Car();
}
it seem that by passing car by ref can null the reference of the car,
or change the reference of the car, it can do more that just
by Change(Car car) (i.e. without the ref keyword.
Then why we not always add ref keywords to the method, so
more capabilities are achieved ? What are the disadvantages
of using ref ??
Thanks
|
|
|
|
|
The disadvantages of ref keyword is it can change the reference of car.There is a situation we don't want change the reference of car,so we don't need use the ref keyword.
When you want pass type value parameters and want change the variable pass to method ,you use the ref keyword.and if you dont't want change the variables pass to method,you shoudn't use the ref keyword.
le van giang
|
|
|
|
|
Thanks
But it seems there are no harm to change the reference by ref.
And this add more functionality by using ref (except we cant
pass property and not initialized object reference to it ).
So, in what other situation that it is harmful to use ref ?
|
|
|
|
|
In any case when changing the reference will make you lose the reference to an object that you need.
Example:
You create a SqlParameter object and add it to a SqlCommand object. Now the command object also has a reference to the parameter.
You send your reference to a function that replaces the parameter with a new parameter.
You execute the command, which will place data in the parameter you added to it.
You try to retrive the data using your reference to the parameter, but as it no longer references the correct parameter, you won't get the data.
---
b { font-weight: normal; }
|
|
|
|
|
|
Hi Guyz,
Has anyone experimented with generating powerpoints from XML file? Need to do this as a part of developing a Learning Objects Repository.
Any help/comments would be greatly appreciated.
Thanks!
Sylvester, Asil Gerard
sylvester_26ATyahooDOTcom
|
|
|
|
|
In msdn library no sample.
It only have... "Birthdate < #1/31/82#"
But I need "Birthdate - Today"
Sorry, for bad English
Thank You.
|
|
|
|
|
using System;
namespace rfid_Beta
{
class MainClass
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
when i tried to execute the above codes, nothing seems to happen. Any ideas why?
|
|
|
|
|
I guess you are creating a windows application, which has no console and therefor nothing happens.
www.troschuetz.de
|
|
|
|
|
Add followed expression at the end
Console.Read();
the output screen will delay until you press anykey.
using System;
namespace rfid_Beta
{
class MainClass
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Console.Read();
}
}
}
le van giang
|
|
|
|
|
Try putting in Console.ReadLine(); just below Console.Writeline
|
|
|
|
|
Looks like it should work fine. How are you executing it? In a console window? Since it is a console app, you should be running it from the command line in a console window.
If you are running it from the IDE (Visual Studio), then look in the "Quick Console" tab down at the bottom. (That's what is is called in VS.Net Beta 2 -- I think it had a different name previously, but I forget exactly what; anyway, look for a likely output window tab at the bottom of the IDE).
By the way, it's "code" not "codes".
Matt Gerrans
|
|
|
|
|
Hi,
I have developed an application that runs on P.D.A as a final part I have upload the result to the Server from my P.D.A. database(SQlCe 2.0). I have written the web services programme on the server side,I a sending an array of objects to theservwer from P.D.A. Its working fine with the connection.But when i try to do the same using the G.P.R.S. its showing the following error
"MDCSTest.exe
WebException
Unable to read data from the transport connection
Application:Run+0xf
Form1:Main+oxa
Praveen.N
|
|
|
|
|
Hi Everybody,
How to open a new form when click on row of Datagrid in C#.
Thanks
|
|
|
|
|
Look into the dataGrid MouseUp event and DataGrid.HitTestInfo (to check if a row was clicked)
Then just call your form as normal Form1 f = new Form1(); f.show();
|
|
|
|
|
|
I would like to input data through a COM port and need to know how to tell C# to look for the COM port and to communicate witht he device atttached.
|
|
|
|
|
|
Hi all,
I am overridding WndProc method in C# for RichTextBox to handle the paste functionality.If i inherit TextBox, the message id 0x0302 gives WM_PASTE handler, but if i use RichTextBox it is not working. Is there any specific WM_PASTE message id for rich textbox. How can i know various MessageIds for RichTextBox.
|
|
|
|
|
Did you try using Spy++ and watching what happens when you paste text into the richtextbox.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi senthil, thanks for your reply. But i am not aware of spy++ tool,could you tell me where can i download and how can i utilize that to check the paste operation.
Thanks
Muthu.
|
|
|
|
|
Thanks senthil, i have seen spy++, but it is not logging the message when i click ctrl+v for rich textbox. But if i use textbox the message WM_PASTE is logged.Is it a problem in .NET RichTextBox..??
|
|
|
|
|
I have a form-based user for a user to select recepient from the current email addresses in the exchange server. How do I go about extracting this address list from MS Exchange?
Thomas
|
|
|
|
|
I have a form that contains a combobox with values of item1, item2, and item3. I am wanting to retrieve a value from a database and select the correct value from the options of the combobox during the loading of the form. What might be the best way to do this?
|
|
|
|
|
Just set the text property of the combobox.
Christian Graus - Microsoft MVP - C++
|
|
|
|