私は、ユーザーからの日付入力を格納する配列を持っているが、私は削除または配列で入力されたすべての日から(基本的に、私は月を削除する)最初の2つの文字をトリミングしたい:配列の日付文字列(MM/dd/yyyy)から最初の2文字を削除するにはどうすればよいですか?
class MainClass
{
{
//Main Program....
}
public static int GetInput (string[] date)
{
int loop;
(for int i=0 ; i < loop ; i++)
dArray[i] = Console.ReadLine();
}
}
class OtherClass
{
//Required data properties, etc...
public string TrimFirstTwoMonthChar(string dateInput)
{
char[] delimiter = {'/', '-', .... }
string[] monthNumberRemoved = dateInput.Split(delimeter);
// How would I code the rest of this function so that it removes the first 2 characters from "MM/dd/yyyy".
//Keep in mind I have also allowed users to input the date in formats like
//"M/dd/yyyy" (such as 3/07/2011 vs 03/07/2011)
//so sometimes I would only need to remove ONE NOT TWO of the month character //
}
}
あなたはコメントの説明に言い直す必要があります。論理的に考えると、最初の2文字<10の値なら 'm/dd/yyyy 'else' mm/dd/yyyy'はもちろん部分文字列関数を使って長さなどを調べます。 – MethodMan
(int i = 0; i
llouk