אני אמור לכתוב את התרגיל במתודה, כתבתי משהו אבל יש לי בעיות בהמשך, המתודה שלי מקבת את הסטרינג בפורמט dd/mm/yyyy, ממירה את הסטרינג ל-int ומכניסה את ה-3 int's למערך, מעכשיו הבעיות שלי מתחילות, איך אני רושם בהמשך שידפיס לי את כל ה-int's למסך ?
קוד: בחירת הכל
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace T266B
{
class Program
{
//define method
static int stDate(string date)
{
int ArrayIndex = 0;
string temp = "";
//define array
string[] stArray = new string[3];
int[] NumArray = new int[3];
//seperate the date to day, month, year, convert to int and put into array
for (int i = 0; i < date.Length; i++)
{
if (date[i] != '/' & date[i] != ' ')
{
temp += date[i];
}
else if (temp != " ")
{
int Number = int.Parse(temp);
NumArray[ArrayIndex] = Number;
Number = 0;
temp = "";
ArrayIndex++;
}
}
return 0;
}
static void Main(string[] args)
{
//read date
Console.Write("Enter Date (dd/mm/yyyy): ");
string date = Console.ReadLine();
date = date + " ";
int result = stDate(date);
}
}
}