|
You're asking for reference semantics on value types. You can do this between methods using the ref keyword:
int i = 5;
MyFunc(ref i);
void MyFunc(ref int someInteger)
{
someInteger = 10;
}
But in order to get reference semantics throughout any piece of code, not just between methods, you have 2 options.
1. Use unsafe code. Just as it is in C, you can use pointers the same as you would in C. Only caveat is that you need to compile with the /unsafe switch, and also mark code that uses pointers with the unsafe keyword. For example, the following is perfectly legal C# code:
unsafe
{
double someVal = 200;
double *c = &someVal;
}
2. Use a wrapper class to wrap your value, thus automatically giving it reference semantics:
public class Wrapper<T>
where T : struct
{
public T Value;
}
Wrapper<double> Xman = Xset.Xmax.X;
Wrapper<double> Xmin = Xset.Xmin.X/
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Connor's Christmas Spectacular!
Judah Himango
|
|
|
|
|
No, you can't reference a value type.
You can get a pointer to the values, but that would cause two nasty things:
1. You would have to use the fixed keyword to fix the object in memory. The garbage collector doesn't really like if you fix objects for a long time, as it wants to move stuff around sometimes.
2. You would have to use the unsafe keyword whenever you would access the values, or make the entire code unsafe (which is an extremely bad idea).
If it's only the simplicity in the code you are after, just declare properties to access the values:
private double Xmax { get { return Xset.Xmax.X; } set { Xset.Xmax.X = value; } }<br />
private double Xmin { get { return Xset.Xmin.X; } set { Xset.Xmin.X = value; } }
---
b { font-weight: normal; }
|
|
|
|
|
To both of you,
Thanks for your clear responses. I particularly like making Xmax and Xmin local properties... didn't think of that.
I think I'm good to go now.
|
|
|
|
|
How do I send Arguments to an executeable?
Any help is appreciated.
<marquee bgcolor="#000000" loop="-1" scrollamount="6" width="100%">
Wacky waving inflateable arm flailing tube man!
|
|
|
|
|
It depends, do you want to send an argument during debug, or for a 'released' exe?
If you are debugging you want to go to your projects properties (not the solutions) and under the 'debug' tab there's a textbox for 'Command Line Arguments'.
For use with an actual exe, create a shortcut to the exe, open the shortcuts properties. There will be a textbox titled target (in winxp). put the path that's in the in quotes ("path\to\exe") and then you can put any arguments behind that.
|
|
|
|
|
|
|
Hi All!
I have a problem on my PC, when i am trying to send email i get an error, a very large one, what the hell is the problem( i dont use outlook on my PC, is it relevant?)
use: System.Web.Mail.SmtpMail.Send("y@hotmial.com","y@hotmail.com","Test","Test");
error: System.Web.HttpException: Could not access 'CDO.Message' object.
Thanks
and another small thing, i wrote a function in my html page, i did:
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
now i got the page that i wanted, how can i use this object in my C# code page?with document?how?
Thanks again
|
|
|
|
|
Just guessing here, but did you set the SmtpMail.SmtpServer property correctly?
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
what do you mean?
i do not know what it this? and where i cahnge it?
|
|
|
|
|
yes i did!!
sorry, did not know that you mean about the function.
my Bad.
|
|
|
|
|
|
I can see that you are new to the SMTP protocol. To send an email, you need a SMTP server, which is a machine specialized in routing the email to its recipient.
SmtpMail.SmtpServer = "smtp.mydomain.com";
Do you try to do this from home or at work? If it is at home, you probably have, in the documentation from your ISP, the name of this server. If at work, ask the system admin.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
can i download it?
how do i install it?
And yes i am very new with this, i only know that at work i tried it and it went smooth as baby's BBBBB.
|
|
|
|
|
I have had the same issue before.
I would send an email message to my own account and it would work fine,
then I would open my email application and check that I got it. Which I
did. I would then close my email app and all of a sudden my application would stop working. (got the same error you're getting).
I tried everything until I finally figured out that if I re-opened my email
app it would mysteriously start working again.
It seemed to be that my email app (outlook) was taking over from cdonts
once it was opened and only a reboot would fix the problem.
Hope this helps.
|
|
|
|
|
Go to IIS
Default SMTP Virtual Server
Right click on that ...>Properties...>
Assign the IPAddress in general properties
check whether anonymous access is checked or not
Nothing is Impossible Even Impossible says I'MPOSSSIBLE
|
|
|
|
|
Hi !
I've a table with the following fields :
ID,field1,field2,field3,... and also in Form 1 , I have 2 buttons(Next,Prior) for going to the next Record or before record .
for taking a report , i have to add another form(Form2) and put a CrystalReportViewer control in it .
I want to take a report , for example when my Record number is :4 , how can i do it ?
please help me !
Thanks,
s_mostafa_h
|
|
|
|
|
I would like to increase the height of the rows in the datagrid whenever data is binded to the grid.
So, How do I get the notification whenever the datagrid is binded to a Datasource.
The DataSourceChanged event occurs only when there is a change in the DataSources value. When I bind the same datasource to the datagrid, the DataSourceChanged event won't fire.
How can this be handled.
Thanks in advance.
Subrahmanyam K
|
|
|
|
|
hi Subrahmanyam K!
try to shadow the DataSource property, like this:
public new object DataSource
{
get {return base.DataSource;}
set
{
base.DataSource = value;
}
}
hope that helps!
microsoc
|
|
|
|
|
I have learnt that in VS2005 you can use dataadapters to connect to a stored procedure in a database and wite to the back end (delete, update, insert).
This seems to have a lot less code than if you start using code such as sqlcommand, sqlconnection, parametrs...
I know for sure that there are disadvantages in using the dataadapters approach instead of using the sqlcommand, etc...
What are the disadavatages please?
Thanks
|
|
|
|
|
The disadvantage is that you don't have fine-grained control over how and when the connection is opened, how long the command should try to execute before giving up, custom error handling when something goes wrong, to name just a few. If you're ok with losing some power in order to be able to write less code (which means fewer bugs), then DataSets and DataAdapters are for you.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Connor's Christmas Spectacular!
Judah Himango
|
|
|
|
|
The disadvantage is that
No control over connection and command for Developer
We will be know that something happening inside but not how and when?
Senior Software Engineer
Nothing is Impossible Even Impossible says I'MPOSSSIBLE
|
|
|
|
|
hi all !
I want to put MonthCalendar into ComboBox , in how if i click the the button of ComboBox ,instead of ListItem , the MonthCalendar control is appeared .how can it possible !
thanks !
Regards !
s_mostafa_h
-- modified at 10:54 Wednesday 1st March, 2006
|
|
|
|
|
Why not try a DateTimePicker...
|
|
|
|
|
because , DateTimePicker based on Julian date (Christian date) but i want to take a Arabic or Persian Date .Is there a DateTimePicker control based on Arabic or Persian ? if not , how can i convert ...
Regards ,
s_mostafa_h
|
|
|
|