|
Please find below:
public static void Main (string[] args)
{
if (args.Length > 0)
{
System.Console.WriteLine (args[0]);
try
{
long number = long.Parse (args[0]);
System.Console.WriteLine ("Number = " + number);
}
catch (System.FormatException e)
{
System.Console.WriteLine ("FormatException" + e);
}
return;
}
System.Console.WriteLine ("Please enter a number");
}
Cheers!!
Brij
|
|
|
|
|
There's this cunning command called GetCommandLineArgs in the Environment class. This should help.
|
|
|
|
|
|
I wonder what exactly you want. But for getting the controls on a page you can have a loop like this
foreach (Controls c in this.Controls)
Ahsan Ullah
Senior Software Engineer
|
|
|
|
|
I have seen some strings formatted like @"Hello World!", or something like that in code i have downloaded on the internet, and i was really wondering what that '@' symbol does. What's the difference between "Hello World!" and @"Hello World!"? Just curious.
void Play() { try { throw Ball(); } catch (Glove) { } finally { Play(); } }
"Failure is only the opportunity to begin again, this time more wisely."
"Don't ask for a light load, but rather ask for a strong back."
|
|
|
|
|
In the case of @"Hello World!" I don't believe it does anything. However
in a directory string
@"C:\Program Files\Common Files"
you don't have to escape the "\" like you would with out it.
"C:\\Program Files\\Common Files"
|
|
|
|
|
|
Ok, thanks. Live and learn.
void Play() { try { throw Ball(); } catch (Glove) { } finally { Play(); } }
"Failure is only the opportunity to begin again, this time more wisely."
"Don't ask for a light load, but rather ask for a strong back."
|
|
|
|
|
I use it a lot when I want large strings, like pieces of xml, to be readable in code.
with @ you can write something like this:
string xml = @"
<xml>
<test>
<value>1</value>
<value>2</value>
</test>
</xml>"
instead of:
string xml = "<xml><test><value>1</value><value>2</value></test></xml>"
Dawn is nature's way of telling you to go to bed.
|
|
|
|
|
Hi,
Can anyone guide me on how to get info on the key(s) pressed?!
TROJAN LIKE LOL
I can disable numbers or chars to being pressed in order to do some validations in c#, but that i can´t do.
Just give me a link if you know something about it
Thanks
nelsonpaixao@yahoo.com.br
|
|
|
|
|
|
i smell a key logger
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
yes yes yes
nelsonpaixao@yahoo.com.br
|
|
|
|
|
This topic is more about the registry then C# itself as i already know how to edit the registry in C#.
I have created a basic webbrowser that i have added some personal features to with the .NET WebBrowser control. I want to be able to set this as my default webbrowser that opens urls when clicked say in an msn convo or when put in the "Run" box.
I am using the following code to edit the registry:
string root = "htmlfile\\shell\\open\\command";
RegistryKey rKey = Registry.ClassesRoot.OpenSubKey(root, true);
rKey.SetValue("", Application.ExecutablePath + " %1");
rKey.Close();
And that works fine, It edits the registry to the path for my browser, and it also does the same in HKEY_CURRENT_USER with the same path.
But yet still when i click a link or run a url in the run box it opens Firefox.
Could someone offer any advice on how to set it to my browser please?
Thanks for your time in reading :]
|
|
|
|
|
I am trying to create a report. I have my main page set up and it is working fine.
I did set it to where you can click a name that is listed and it takes to you a different report passing the name in a parameter. (This works fine).
Now I need it to pull information from a database on the second form that we are on where the name (from the parameter) is equal to in a name column in a database. I see how to do this. This is the error I get:
A data source instance has not been supplied for the datasoure "ID_ITHELPDESKV2_MDFDataSet_UserInfo".
If I run this first in the Report Viewer instead of my main screen it works fine if I manually enter the data in. It is something with going from one report to the other (jumping). I have added that above to the DataSources on that report.
What is going on?
|
|
|
|
|
Anyone have any idea? I am using C#
|
|
|
|
|
I am trying to make something that will write data to a file at the specified position using the IO.StreamWriter class. Here is what i have
public static void EncodeData(string Data, string Path, long Index)
{
StreamWriter stream = new StreamWriter(Path, true);
stream.BaseStream.Position = Index;
stream.Write(Data);
stream.Close();
}
Problem is, that throws an exception that says "Unable seek backward to overwrite data that previously existed in a file opened in Append mode.". When i open the file so it's not in append mode, it will write at the specified position, but it will override the entire file. Just to be clear, i want this to insert the data, without overriding anything.
void Play() { try { throw Ball(); } catch (Glove) { } finally { Play(); } }
"Failure is only the opportunity to begin again, this time more wisely."
"Don't ask for a light load, but rather ask for a strong back."
|
|
|
|
|
Sounds like the value in index is not in the end of the file. However, if you have opened the file in append mode, why do you want to change position? I'm under the impression that the position is already at the end of the file.
|
|
|
|
|
I don't want to append to the end of the file. I want to insert text at X position inside the file.
void Play() { try { throw Ball(); } catch (Glove) { } finally { Play(); } }
"Failure is only the opportunity to begin again, this time more wisely."
"Don't ask for a light load, but rather ask for a strong back."
|
|
|
|
|
In that case I believe you have to do it in parts:
- create a stream for new file / memorystream
- read first portion of the original file and write it to output stream
- append needed data to output stream
- read the second portion of the original file and write it to output stream
- close the original file and write over it based on previous output stream.
Of course this can be varied (read only the second portion into memory and write over it in file with new data + what's in memory etc).
|
|
|
|
|
hi
how can i show time(now)in lable?
please describe complete
thanks a lot
|
|
|
|
|
yourLabel.Text = DateTime.Now.ToString();
|
|
|
|
|
label1.Text = DateTime.Now.ToLongTimeString();
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Label1.Text = DateTime.Now.ToString("dd-MM-yyyy");
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you then save my time by voting my post.
|
|
|
|
|
If you ever want to be a programmer, or anything remotely resembling one, you will need to be able to use books and google to answer these sort of extremely basic questions.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|