static bool fillMyStruct(out mystruct bla) { Console.WriteLine("wert eingeben bitte: "); bla.wert = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Wertname: "); bla.wertname = Console.ReadLine(); return(true); }
public static void Main() { mystruct my = new mystruct(); my.name = "arif"; my.age = 22; Console.WriteLine(my.Name + " " + my.Age); //Console.WriteLine(m.Name + " " + m.Age); }
static bool fillMyStruct(out mystruct bla) { bool isEnde = false; do { Console.Write("Bitte Wert eingeben:"); isEnde = double.TryParse(Console.ReadLine(), out bla.wert); }while (isEnde != true); isEnde = false; Console.Write("Bitte Wertnamen eingeben (oder ENDE für Ende):"); bla.wertname = Console.ReadLine(); //Kontrollausgabe Console.WriteLine("fillMyStruct: Wert:" + bla.wert + " Wertname:" + bla.wertname); if (bla.wertname == "ENDE") { return(true); } else { return(false); } }
private void ToolStripButton2_Click(object sender, EventArgs e) { try { if (toolStripTextBox1.Text == "") { MessageBox.Show("Please fill Year field"); } else { int yearValue = 0; yearValue = int.Parse(toolStripTextBox1.Text.ToString()); mystruct mm = new mystruct(); date ss = new date(); mm = ss.cnvToEnglish(12, 26, yearValue); textBox6.Text = mm.year.ToString(); textBox4.Text = dataGridView1.Rows[SelectedRowIndex].Cells[5].Value.ToString(); date s = new date(); var num1 = int.Parse(textBox4.Text.IndexOf("/").ToString()); var num = int.Parse(textBox4.Text.LastIndexOf("/").ToString()); int num3 = int.Parse(textBox4.Text.Length.ToString()); int num4 = num3 - num; int y = 0, mo = 0, d = 0; var t = num - num1; string to = ""; if (t == 2) { to = int.Parse(textBox4.Text.Substring(5, 1)).ToString(); mo = int.Parse(to); } else if (t == 3) { to = int.Parse(textBox4.Text.Substring(5, 2)).ToString(); mo = int.Parse(to); } string too = textBox4.Text.Substring(0, 4).ToString(); y = int.Parse(too); string tooo = textBox4.Text.Substring(num + 1, num4 - 1).ToString(); d = int.Parse(tooo.ToString()); mystruct m = new mystruct(); m = s.cnvToEnglish(mo, d, y); textBox1.Text = m.year.ToString(); textBox2.Text = m.month.ToString(); textBox5.Text = m.day.ToString(); printPreviewDialog1.Document = printDocument1; printPreviewDialog1.ShowDialog(); } } catch (Exception ex) { MessageBox.Show("error\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public mystruct cnvToEnglish(int mm, int dd, int yy) { if (yy < 2000 || yy > 2089) { MessageBox.Show("Supported only nepali year between 2040-2089"); } if (mm < 1 || mm > 12) { MessageBox.Show("Invalid Date"); } if (dd < 1 || dd > 32) { MessageBox.Show("Invalid Date"); } int[] month = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; //non leap year int[] lmonth = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; //leap year int isLeapYear(int year) { if (year % 100 == 0) { if (year % 400 == 0) { return(1); } else { return(0); } } else { if (year % 4 == 0) { return(1); } else { return(0); } } } /**currently can only calculate the date between BS 2013-2079...**/ int def_eyy = 1983, def_emm = 4, def_edd = 14 - 1; //spear head english date... int def_nyy = 2040; //spear head nepali date... int total_eDays = 0, total_nDays = 0, a = 0, day = 4 - 1; //all the initializations... int m = 0, y = 0, i = 0, j = 0; int k = 0; //to access the array data int numDay = 0; for (i = 0; i < (yy - def_nyy); i++) { //total days calculation...(nepali) for (j = 1; j <= 12; j++) { total_nDays += nepali[k, j]; } k++; } //final year's month calculation...(nepali) for (j = 1; j < mm; j++) { total_nDays += nepali[k, j]; } total_nDays += dd; total_eDays = def_edd; m = def_emm; y = def_eyy; while (total_nDays != 0) { if (isLeapYear(y) == 1) { a = lmonth[m]; } else { a = month[m]; } total_eDays++; day++; if (total_eDays > a) { m++; total_eDays = 1; if (m > 12) { y++; m = 1; } } if (day > 7) { day = 1; } total_nDays--; } numDay = day; mystruct my = new mystruct(); my.year = y; my.month = m; my.day = total_eDays; return(my); }
public static void Artir(ref mystruct mst) { mst.Deneme1 = 25; }