ch7_09.cs
来自「《c#技术内幕代码》」· CS 代码 · 共 55 行
CS
55 行
using System;
class CH7_9
{
public static String Right( string s, int len )
{
// How many characters to skip?
int nSkip = s.Length - len;
// Copy
string temp = "";
for ( int i=nSkip; i<s.Length; ++i )
temp += s[i];
return temp;
}
public static int GetArgsToCommand( int nPos,
String[] array )
{
// Starting at nPos, work our way through
// the array looking for something that
// does NOT start with a hyphen
int nEnd = nPos;
for ( int i=nPos; i<array.Length; ++i )
{
if ( array[i][0] == '-' )
break;
Console.WriteLine("Command Argument: {0}",
array[i] );
nEnd = i;
}
return nEnd;
}
public static void Main(String[] args)
{
// First, just print them out
for ( int i=0; i<args.Length; ++i )
{
Console.WriteLine("Argument {0} = {1}",
i, args [i] );
}
// Parse simply for instructions
for ( int i=0; i<args.Length; ++i )
{
if( args[i][0] == '-' )
{
string cmd = Right(args[i], args[i].Length-1);
Console.WriteLine("Command {0}", cmd );
i = GetArgsToCommand( i+1, args );
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?