|
Hello experts,
How can I manage global variables through out the application in C#.Net...?
Regards
Pankaj Joshi
If you want to shape your dreams into reality, please wake-up...
|
|
|
|
|
Use a static class. For instance:
public static class MyClass
{
public string MyKey = string.Empty;
} To refer to it in other places, you would use MyClass.MyKey = "Hello";
|
|
|
|
|
Create a public class named like Global
and make some public static property and access it in application anywhere
Parwej Ahamad
g.parwez@gmail.com
|
|
|
|
|
Hello!
Ive been trying to make a regular expression remove everything from a string that´s not a numeric d1-10 with comma and d1-2 after. The expression looks like this:^\d{1,10}(\,)?(\d{1,2})?$, and I try to use it like this:
original = Regex.Replace(original, @"^\d{1,10}(\,)?(\d{1,2})?$", "");
but this amounts to nothing. If original for instance would be "345,46 £" I would want the £ and the blankspace removed. Does anyone know what Im doing wrong?
|
|
|
|
|
There are a couple problems with your code and regex.
First, the regex will match the correct pattern of 345,46, but only if it's at the beginning and end of the line (because you specify the ^ and $ before and after it). Because your input string has " £" at the end, your regex won't match.
Assuming that "345," is not a valid number, then the "(\,)?(\d{1,2})?" part should be "(,\d{1,2})?". If "345," is a valid number, then the "(\d{1,2})?" part should really be "\d{0,2}". I'm going to assume that "345," is not valid though.
Now, the actual parameters to the Replace method are incorrect also. Assuming you don't have any back references in the "replacement string", then whatever is match will be replaced. So you would be replacing the number, not the "extra" stuff.
Based on this your regex needs to be "^.*?(?<num>\d{1,10}(?:,\d{1,2})?.*?$", and your replacement string needs to be "${num}". This will extract the FIRST number to match the pattern. So in "123,4 dd 567,89", the resulting string will be "123,4".
Basically, we match the entire input string with our regex, but we save the number in the group named "num". Then we reference that group to generate the output.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
|
No problem. Please get the regex from my previous post again, though. I forgot to use & l t ; so the <num> part was removed.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Hi again!
I´ve tried your example but cant quite get it to work. In its original form I get an error message, "Not enough )'s". If I alter the regex to look like this
original = Regex.Replace(original, @"^.*?(?<num>\d{1,10}(?:,\d{1,2})?.*?$)", "${num}")
nothing happens with my string.
|
|
|
|
|
Sorry, the missing paren goes before the last .*?, so:
^.*?(?<num>\d{1,10}(?:,\d{1,2})?).*?$
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
|
Hi
Few question if any one knows answer plz let me know
1. What is MAC address ?
2. Is it unique to every system in a network
3. How to know the MAC Address of Clients System.
4. If Q2 answer is yes then how to find all the MAC address of the ' Systems connected in a network using C# code
Plz if any idea also share with me
REGARDS
Tiwari
its me sid
|
|
|
|
|
sindhutiwari wrote: 1. What is MAC address ?
MAC address - Wikipedia[^]
sindhutiwari wrote: 2. Is it unique to every system in a network
Yes
sindhutiwari wrote: 3. How to know the MAC Address of Clients System.
Goto command prompt and type ipconfig/all
sindhutiwari wrote: 4. If Q2 answer is yes then how to find all the MAC address of the ' Systems connected in a network using C# code
Use ManagementClass in System.Management
|
|
|
|
|
Thanks for ur reply i am having a code to know the mac address ...i am getting the mac address of my system along with that i am getting some other things also please see to this and help me out
ManagementObjectSearcher query = null;
ManagementObjectCollection queryCollection = null;
query = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration");
queryCollection = query.Get();
foreach (ManagementObject mo in queryCollection)
{
if (mo["MacAddress"] != null)
{
MessageBox.Show(mo["MacADDress"].ToString());
}
}
its me sid
|
|
|
|
|
It should be noted, however, that it's possible to spoof a computer's MAC address, so two systems could be given the same address. However, this would cause all sorts of networking problems.
|
|
|
|
|
Hi guys,
I have a C# 2.0 project in VS 2005 under Vista. When I try to debug it, it throws Error:
The requested operation requires elevation
I can build it and when run from .exe it throws the UAC dialog.
I don't know what's so special about this project that it needs to be run under administrator rights. It is a regular win app with one attached dll. That attached dll is used in other projects too, which don't demand "elevation". I know I could probobly use the mt.exe utility but I don't want to, because there is no reason to bother user with aksing for administrator rights that are not required for this app.
any ideas?
zilo
|
|
|
|
|
hello,
how can i write the debug trace to a log file
regrads
dghdfghdfghdfghdgh
|
|
|
|
|
One way to do it would be to use the TraceListenerTextWriter class. This[^] sample shows you how.
|
|
|
|
|
Google it.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hello friends,
I made an application on C# .Net using Visual Studio 2005.
Added Help section also through .chm file. Everything working fine when i compile and run application. F1 shows help also.
But after creating .msi or .exe file when I'm installing Software then its not Shows help manually or at pressing f1 key.
Help me as possible....
Here is an Screenshot[^]
modified on Friday, December 14, 2007 7:47:00 AM
|
|
|
|
|
Did you include this .CHM file in the setup?? After the installation, does the .CHM file show up in the same folder as your .EXE, somewhere under the Program Files folder??
|
|
|
|
|
hello sir
thanx for your kind reply.
The setup is working now. I was doing the same you described above.
but there was an error of path in HelpProvider of .chm file only. In my application i put .chm somewhere and was giving path as ..\..\help.chm. In this case it was not working after installation through. Then i made its path to help.chm only and moved the .chm file accordingly into the bin folder. Compiled and run through F5 and through .msi setup. Both are working now. Let me know if you have anyother...
Thanx again Mr. Dave
Any Movie, Software, Song, Game and many more.... Only at Developer's Solution
http://www.devsol.co.nr
Search Any Torrent You Want
A Software for Torrent search only....
Must check it
...VAIBHAV SARAN
vikysaran@gmail.com
|
|
|
|
|
I have some question:
a) In debug mode when we press F11 then it shows next step,
like this can debug backward, means previous step.
b) What is use stepInto, stepOver.
c) When we put a breakpoint there is condition clause,
how can we use this. Suppose I want to hit a breakpoint only when
the value of x=10.
Is this can be done.
I am using vs2003.net & debugging a C# application.
Thanks in advance.
|
|
|
|
|
a) F11 Steps into a funktion when you debug. Shift+F11 Runs the funktion to the end and then stop at the call to the function for you to continue debugging (jumps out of the function).
You can move the debugarrow if you want to jump over something or run some code again. If the code is i++; then i++; will be done again that means if you run the code twice i = i + 2;
b) Stepinto = F11 , stepOver = F10
c) Rightclick the breakpoint and choose condition... Write x = 10; in the textbox and check the radiobutton "is true".
|
|
|
|
|
1 - you can use 'set next statement' to 'go back', but you can't rewind the statement that just ran, no
2- step into goes into a method when you're calling it
3 - you set the condition to x == 10 and it will only stop if x is 10 when this code is run, this is important. It won't stop the moment x is 10, but the iteration over that breakpoint where x is 10.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Subject in a Mailmessage sent with SmtpClient.Send(Mailmessage) doesn't replace spaces with =20.
If a space exists in the subject then it is treated as spam.
A solution to this was to replace it my self like this
mailMessage.Headers.Add("subject", subject.Replace(" ", "=20"));
This worked great but now I have installed framework 2.0 service pack 1 and this removed the possibility to put the subject in the header. It won't show in the received email any more
Does anyone have any idee on how to get correct spaces in a subject?
|
|
|
|