PC Review


Reply
Thread Tools Rate Thread

What class parses to get Main()'s args?

 
 
=?Utf-8?B?U3R1YXJ0IE0uIFJheQ==?=
Guest
Posts: n/a
 
      23rd Jan 2005
Hi,

For some test code I am writing, I want to convert a string of characters
that I would theoretically enter on the command line into the string array
that is passed to my program's Main() method.

For example, on the command line I may have:
c:>program.exe "This is a test"

Whatever calls Main() will call using an array with a single string rather
than four strings, because of the 3 spaces. Anyway, what is the parser
class/method that converts "This is a test" to the appropriate string args
array? I am looking to call Main() from a test class and to parse the
string entered on the virtual command line just as it is parsed into a string
array when executed from the command line.

Thanks,
Stuart
 
Reply With Quote
 
 
 
 
Mattias Sjögren
Guest
Posts: n/a
 
      24th Jan 2005
Stuart,

>Anyway, what is the parser
>class/method that converts "This is a test" to the appropriate string args
>array?


There's no managed class that does that. It's done in the CLR startup
code (I haven't looked exactly how they do it, but they may be using
the CommandLineToArgvW API).



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
 
Reply With Quote
 
=?Utf-8?B?UElFQkFMRA==?=
Guest
Posts: n/a
 
      24th Jan 2005
Try using string.Split() ?
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
read lines from textfile and treat them as Main(args) Ken Snyder Microsoft C# .NET 4 23rd Jun 2008 04:18 AM
call a mnuFileNew_Click method from a Main MDI class from another class (can be a MdiChild class.. )? M. G, Microsoft Dot NET Framework Forms 1 31st May 2006 06:28 AM
Is there a class or method to construct url args or extract url args? Ken Varn Microsoft ASP .NET 2 22nd Jun 2005 01:26 PM
how do I make brackets [] take specific args (like the DataRow class) Chris LaJoie Microsoft C# .NET 2 3rd Sep 2003 03:15 PM
How do I expand wildcard arguments in the Main (Stirng [] args) ? rogdh Microsoft C# .NET 9 2nd Aug 2003 07:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:20 AM.