|
hi,
zhe subject is that
class Class1 {
private string str = "class1.str";
private int i = 0;
static void StringConvert(string str) {
str = "string being converted.";
}
static void StringConvert(Class1 c) {
c.str = "string being converted.";
}
static void Add(int i) {
i++;
}
static void AddWithRef(ref int i) {
i++;
}
static void Main() {
int i1 = 10;
int i2 = 20;
string str = "str";
Class1 c = new Class1();
Add(i1);
AddWithRef(ref i2);
Add(c.i);
StringConvert(str);
StringConvert(c);
Console.WriteLine(i1);
Console.WriteLine(i2);
Console.WriteLine(c.i);
Console.WriteLine(str);
Console.WriteLine(c.str);
Console.Read();
}
tell me why "Console.WriteLine(str);" and "Console.WriteLine(c.str);"
zhe two sentence have two different results!
I know that zhe "string" is reference type!
but here i am puzzled!
modified on Saturday, June 20, 2009 8:09 AM
|
|
|
|
|
While you are correct that string is a reference type, you cannot change which string the local variable str in Main is referencing from the StringConvert function since you pass it by value. All you can do is make the parameter to StringConvert refer to another string, which will have no effect outside the function.
In the case where you passed a Class1, you are modifying the reference contained in the object referred to by the parameter, which is the same object referred to in Main. If you had put the line c = new Class1(); as the first line in StringConvert, it would no longer change the value in Main because the parameter in StringConvert would now be referring to a different object.
|
|
|
|
|
i want to send mail to yahoo mail automatically using c# code.
|
|
|
|
|
|
I want a Porche.....
Seriously, what have you tried ? Why do you have a specific issue with yahoo mail ? A quick google leads me to believe that a lot of people are asking this, so perhaps the issue is that yahoo does not support sending mail through a third party, or through the protocols that .NET supports.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Yahoo doesnt provide free smtp/pop3 service so you cannot use your Yahoo id to send mails from any other email client.
To use Yahoo mail you wil have to buy the Pop3 Service from yahoo.
Rishav Raj
http://hashtech.erishav.com
|
|
|
|
|
I have an application I made that simply gets the current directory using System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location goes up a directory level and then runs a file in that directory using System.Diagnostics.ProcessStartInfo and System.Diagnostics.Process.Start. The file works fine if I run it on my computer but if I put the file on a Shared Network Path I get the below error:
Unhandled Exception: System.Security.SecurityException: Request failed.
at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly a
sm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, Secur
ityAction action, Object demand, IPermission permThatFailed)
at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object ass
emblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle
rmh, SecurityAction action, Object demand, IPermission permThatFailed)
at System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet gran
ts, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Objec
t assemblyOrString, SecurityAction action, Boolean throwException)
at System.Security.CodeAccessSecurityEngine.CheckSetHelper(CompressedStack cs
, PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMet
hodHandle rmh, Assembly asm, SecurityAction action)
at Setup.Program.Main(String[] args)
The action that failed was:
LinkDemand
The type of the first permission that failed was:
System.Security.PermissionSet
The demand was for:
<PermissionSet class="System.Security.PermissionSet"
version="1"
Unrestricted="true"/>
The granted set of the failing assembly was:
<PermissionSet class="System.Security.PermissionSet"
version="1">
<IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Read="USERNAME"/>
<IPermission class="System.Security.Permissions.FileDialogPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Unrestricted="true"/>
<IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Vers
ion=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Read="T:\ClientUpdate\"
PathDiscovery="T:\ClientUpdate\"/>
<IPermission class="System.Security.Permissions.IsolatedStorageFilePermission, m
scorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Allowed="AssemblyIsolationByUser"
UserQuota="9223372036854775807"
Expiry="9223372036854775807"
Permanent="True"/>
<IPermission class="System.Security.Permissions.ReflectionPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Flags="ReflectionEmit"/>
<IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Ve
rsion=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Flags="Assertion, Execution, BindingRedirects"/>
<IPermission class="System.Security.Permissions.UIPermission, mscorlib, Version=
2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Unrestricted="true"/>
<IPermission class="System.Security.Permissions.UrlIdentityPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Url="file:///T:/ClientUpdate/Setup.exe"/>
<IPermission class="System.Security.Permissions.ZoneIdentityPermission, mscorlib
, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Zone="Intranet"/>
<IPermission class="System.Net.DnsPermission, System, Version=2.0.0.0, Culture=n
eutral, PublicKeyToken=b77a5c561934e089"
version="1"
Unrestricted="true"/>
<IPermission class="System.Drawing.Printing.PrintingPermission, System.Drawing,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
version="1"
Level="DefaultPrinting"/>
</PermissionSet>
The assembly or AppDomain that failed was:
Setup, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
The Zone of the assembly that failed was:
Intranet
The Url of the assembly that failed was:
file:///T:/ClientUpdate/Setup.exe
Any ideas on how to fix this?
|
|
|
|
|
Obviously, if it can be fixed at all, then it requires you to set the right permissions on your intranet.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
We were actually looking for a way to fix this through code. We don't want to tell everyone that uses our software that they have to change there intranet settings just to run one file.
|
|
|
|
|
i need to make communication between computer to another machine. and this communication like two communication. first i need data from another machine(make sure it is not computer. i have to connect it with usb com port) and then also send acknowledge from computer to another machine.
i did with it serial communciation.but it was text. i need to receive float data and also sending same data. also i need to identyfying where the next string started and when it will finished.
help reply for this as early as
Arpita Patel
|
|
|
|
|
Hi,
The problem of mixing floats and text needs some kind of protocol. One can come up with several schemes, it depends on the kind of [ero[heral device (speed, memory, language), and the relative amount of floats versus text.
For your float data there basically are two ways to approach this:
1. use binary data, i.e. send bytes, not characters.
2. use strings to represent your float data; either apply ToString() when sending, and float.TryParse() when receiving (=more bytes, and some loss of precision); or get the bytes of a float, and turn them into a readable string, e.g. using base64 conversion (=4 ASCII char for 3 bytes of data) or hex (=2 ASCII char for 1 byte of data).
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Perhaps XML serialization?
|
|
|
|
|
as the other device is "not a computer" I doubt XML is the way to go. Chances are the device has limited capabilities (limited CoreMark, few KBs of RAM, hardly an OS, C only, ...) and will dictate the way to go. we'll have to wait and see.
FWIW: Most of the time I avoided exchanging float data with small embedded systems; choosing an appropriate scale maps most physical stuff easily onto 16-bit integers.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
hey, i tried to share data between two form in different project under same solution. i have two project(project A,project B) in one solution and i want to send data from project A to Project B. and also at that time i want to activate form from project B and same time wants to close previous form. please help me in this case. i really stuck with it. i am using windows application in C# and doing serial communication.
please reply as soon as
|
|
|
|
|
arpi8319 wrote: please reply as soon as
?????
If they are in the same solution, means NOTHING. You need to use something like WM_COPYDATA, or if you want to be all modern, use WCF.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Hi,
Use WCF if these 2 projects are running in different app domains. Ensure to,
-Use Named Pipe binding (I assume that both are winform applications and running on same machine)
-Implement duplex contract for notifications.
Let me know if you need help for implementing this.
|
|
|
|
|
What is the command in c# .net to turn off a pc with windows xp ?
|
|
|
|
|
Have you tried to Google[^] for this? There are many articles out there on the topic. On my search the first hit is what you are looking for. Maybe this will help.
In C#, you could use System.Management classes and the WMI class Win32_OperatingSystem.<br />
<br />
The possible flags for controlling the system<br />
<br />
0 = Log off the network.<br />
1 = Shut down the system.<br />
2 = Perform a full reboot of the system.<br />
4 = Force any applications to quit instead of prompting the user to close them.<br />
8 = Shut down the system and, if possible, turn the computer off.
Next time google first and if all else fails post here.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Why not just run shutdown.exe with the correct command-line arguments?
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
|
First question. (Please don't hit me just because I'm stupid.)
I have a short-deadline (90-day) assignment to convert an almost-working Access 2000 application to C#.net. The application has fifty forms, covered with fiddly little fields that have to be precisely aligned. I am relatively inexperienced in C# .Net development, but I have learned the basics, and have completed several applications of a complexity similar to this assignment. The job is easily achievable within the time limit if the forms don't have to be drawn, but for me to draw them to an acceptable quality will take at least 90% of the time available for the project. Plumbing the code behind the forms holds little terror for me, and can be done easily within the time limit.
Here's the question: Does anyone know of existing software (Codeproject article, other article, commercial software, shareware) that can convert MSAccess 2000 forms to the Visual Studio .Net environment? Retaining the names of the objects would be nice, but not necessary, all I really need is the wireframes of the forms with the objects in their prior spatial arrangement. The development platform is XP.
Searching the web, EvolutionOne seemed to offer hope that I could do a three-cornered MSAccess>VB.Net>C#.Net kludge, but drilling down to their demo software found their website hollow. Looks like they died about 2002.
My bosses are willing to spend up to about 500 (US$)for a product that can do this with a short learning curve. Particularly when faced with the costs of hiring a squad of temporary mouse-wranglers to draw the hateful forms within the time allotted.
Any sensible suggestions will be regarded with gratitude.
"To do is to be." [Descartes]
"To be is to do." [Voltaire]
"Do be do be do..."[Frank Sinatra]
|
|
|
|
|
I looked a year or two ago, unfortunately I wasn't able to find anything, and don't think it exists.
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
There is nothing that will convert Access Forms to C#, or any other language for that matter. Access Forms work quite a bit differently from others, so there is no real direct conversion possible.
You're going to have to redesign the forms, by hand.
|
|
|
|
|
Converting the app as a whole would be a massive undertaking, but if I understand correctly the OP would only need something to create the designer code on the real language side. That would be a significantly simpler task, unfortunately AFAIK there's no tool to even do that much.
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
Please visit Microtools.us website at http://www.microtools.us. ANETVC7, Access Whiz Option H can help you to convert Access forms to C#.
|
|
|
|
|