/// <summary> /// /// </summary> /// <param name="pNameParameter"></param> /// <param name="pValuesParameter"></param> public void AddParameter(string pNameParameter, Double?pValuesParameter) { System.Double exemplo = 0; Type pTypesParameter = exemplo.GetType(); AddParameter(pNameParameter, pValuesParameter, pTypesParameter); }
/// <summary> /// /// </summary> /// <param name="pNameParameter"></param> /// <param name="pValuesParameter"></param> /// <param name="pPermitirValorZero"></param> public void AddParameter(string pNameParameter, Double pValuesParameter, bool pPermitirValorZero = false) { System.Double exemplo = 0; Type pTypesParameter = exemplo.GetType(); if (pValuesParameter > 0 || pPermitirValorZero) { AddParameter(pNameParameter, pValuesParameter, pTypesParameter); } else { AddParameter(pNameParameter, null, pTypesParameter); } }
public TokenNumber(TokenType p_Type, int p_line, int p_column, String p_value) : base(p_Type, p_line, p_column) { try { integerValue = Integer.Parse(p_value); type = integerValue.GetType(); } catch (FormatException) { try { floatValue = Float.Parse(p_value); type = floatValue.GetType(); } catch (FormatException) { Console.WriteLine("{0}: Bad Format", p_value); } catch (OverflowException) { Console.WriteLine("{0}: Overflow", p_value); } } catch (OverflowException) { Console.WriteLine("{0}: Overflow", p_value); } }
private void cmb_box_sheet_number_SelectedIndexChanged(object sender, EventArgs e) { int counter; System.Double prgsbrCntr = 0.00; releaseObject(xlRange); releaseObject(xlWorkSheet); this.cmb_box_serial_number.Items.Clear(); if (this.cmb_box_sheet_number.SelectedIndex == 0) { this.cmb_box_serial_number.Text = "--- Select Sheet First ---"; return; } try { xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(this.cmb_box_sheet_number.SelectedIndex); if (xlWorkSheet.Name != this.cmb_box_sheet_number.Text) { int tempCounter; for (tempCounter = 1; tempCounter <= xlWorkBook.Worksheets.Count; tempCounter++) { releaseObject(xlWorkSheet); xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(tempCounter); if (xlWorkSheet.Name == this.cmb_box_sheet_number.Text) { break; } } if (tempCounter > xlWorkBook.Worksheets.Count) { releaseObject(xlWorkSheet); MessageBox.Show("Error in Sheet please check the salary file.", "Error in Sheet", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } xlRange = xlWorkSheet.UsedRange; this.cmb_box_serial_number.Items.Add("Select Name"); for (counter = 1; counter <= xlRange.Rows.Count; counter++) { Object value = null; indx = 0; name = ""; pancard = ""; value = (xlRange.Cells[counter, CELL_POS_INDX] as Excel.Range).Value2; if (value == null) { continue; } if (value.GetType().ToString() == prgsbrCntr.GetType().ToString()) { indx = Convert.ToInt32(value); } if (indx < 1) { continue; } value = (xlRange.Cells[counter, CELL_POS_NAME] as Excel.Range).Value2; if (value == null) { /* name cannot be null */ continue; } else if (value.GetType().ToString() == prgsbrCntr.GetType().ToString()) { /* name field cannot be double too*/ continue; } else { /* copy name string to name variable*/ name = (string)value; } value = (xlRange.Cells[counter, CELL_POS_PAN] as Excel.Range).Value2; if (value == null) { /* name cannot be null */ pancard = " "; } else if (value.GetType().ToString() == prgsbrCntr.GetType().ToString()) { /* name field cannot be double too*/ pancard = " "; } else { /* copy name string to name variable*/ pancard = (string)value; } this.cmb_box_serial_number.Items.Add(indx.ToString() + "_" + name + "(" + pancard + ")"); } this.cmb_box_serial_number.Text = "Select Person"; this.cmb_box_serial_number.SelectedIndex = 0; } catch (Exception) { MessageBox.Show("Select Proper sheet", "Sheet Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btn_create_slry_slip_Click(object sender, EventArgs e) { string relationship; if (this.btn_src_file_path.Text == "Select Salary File") { MessageBox.Show("Select Salary file first", "Salary File Missing", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (this.btn_dest_path.Text == "Select Out Path") { MessageBox.Show("Select out path where files to be saved", "Destination Path Missing", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (this.cmb_box_sheet_number.Text == "Select Sheet") { MessageBox.Show("Sheet number missing.\nSelect Sheet of the file first", "Sheet not selected", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (this.cmb_box_serial_number.Text == "Select Name") { MessageBox.Show("Person name missing.\nSelect name from list first", "Person details Missing", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if ((this.cmb_box_permanent.Text == "Permanent") || (this.cmb_box_gender.Text == "Select Gender") || (this.txtbx_src_file_path.Text == "_______________")) { MessageBox.Show("One or more of optional fields are not changed.\nOutput Salary slip file might not look nice.", "Default value not changed", MessageBoxButtons.OK, MessageBoxIcon.Warning); } string cmbboxselectedtext = this.cmb_box_serial_number.SelectedItem.ToString(); string index_to_check_str = string.Empty; for (int tmpctr = 0; tmpctr < cmbboxselectedtext.Length; tmpctr++) { if (Char.IsDigit(cmbboxselectedtext[tmpctr])) { index_to_check_str += cmbboxselectedtext[tmpctr]; } else { break; } } int index_to_check = Convert.ToInt32(index_to_check_str); string month = this.cmb_box_month.Text + " " + this.num_up_dwn_year.Value.ToString(); string date_str; System.Double prgsbrCntr = 0.00; this.prgsbr_mmh_slry_mkr.Maximum = xlRange.Rows.Count; this.prgsbr_mmh_slry_mkr.Value = 0; /* below this portion is for creating salary slip */ date_str = today.ToString("d"); XImage image = MMHCollegeSalaryMaker.Properties.Resources.rsc_image_mmh_logo; int rCnt = 0; for (rCnt = 1; rCnt <= xlRange.Rows.Count; rCnt++) { indx = -1; Object value; string filepath; string fileContent; value = (xlRange.Cells[rCnt, CELL_POS_INDX] as Excel.Range).Value2; if (value == null) { continue; } if (value.GetType().ToString() == prgsbrCntr.GetType().ToString()) { indx = Convert.ToInt32(value); } if (indx < 1) { continue; } if (indx != index_to_check) { continue; } value = (xlRange.Cells[rCnt, CELL_POS_NAME] as Excel.Range).Value2; if (value == null) { /* name cannot be null */ continue; } else if (value.GetType().ToString() == prgsbrCntr.GetType().ToString()) { /* name field cannot be double too*/ continue; } else { /* copy name string to name variable*/ name = (string)value; } value = (xlRange.Cells[rCnt, CELL_POS_PAN] as Excel.Range).Value2; if (value == null) { /* name cannot be null */ pancard = " "; } else if (value.GetType().ToString() == prgsbrCntr.GetType().ToString()) { /* name field cannot be double too*/ pancard = " "; } else { /* copy name string to name variable*/ pancard = (string)value; } relationship = indx.ToString() + "_" + name + "(" + pancard + ")"; if (relationship == this.cmb_box_serial_number.SelectedItem.ToString()) { } else { continue; } value = (xlRange.Cells[rCnt, CELL_POS_DESIG] as Excel.Range).Value2; if (value == null) { /* if desig field is null then copy ______ */ desig = "________"; } else if (value.GetType().ToString() == prgsbrCntr.GetType().ToString()) { /* if desig field is double then copy ______*/ desig = "________"; } else { /* copy name string to name variable*/ desig = (string)value; } value = (xlRange.Cells[rCnt, CELL_POS_OTHER_FP] as Excel.Range).Value2; if (value == null) { other_fp = 0; } else if (value.GetType().ToString() == prgsbrCntr.GetType().ToString()) { other_fp = Convert.ToInt32(value); } else { other_fp = 0; } value = (xlRange.Cells[rCnt, CELL_POS_BASIC_PAY] as Excel.Range).Value2; if (value == null) { basic_pay = 0; } else if (value.GetType().ToString() == prgsbrCntr.GetType().ToString()) { basic_pay = Convert.ToInt32(value); } else { basic_pay = 0; } value = (xlRange.Cells[rCnt, CELL_POS_GRADE_PAY] as Excel.Range).Value2; if (value == null) { grade_pay = 0; } else if (value.GetType().ToString() == prgsbrCntr.GetType().ToString()) { grade_pay = Convert.ToInt32(value); } else { grade_pay = 0; } value = (xlRange.Cells[rCnt, CELL_POS_DA] as Excel.Range).Value2; if (value == null) { da = 0; } else if (value.GetType().ToString() == prgsbrCntr.GetType().ToString()) { da = Convert.ToInt32(value); } else { da = 0; } value = (xlRange.Cells[rCnt, CELL_POS_HRA] as Excel.Range).Value2; if (value == null) { hra = 0; } else if (value.GetType().ToString() == prgsbrCntr.GetType().ToString()) { hra = Convert.ToInt32(value); } else { hra = 0; } value = (xlRange.Cells[rCnt, CELL_POS_CCA] as Excel.Range).Value2; if (value == null) { cca = 0; } else if (value.GetType().ToString() == prgsbrCntr.GetType().ToString()) { cca = Convert.ToInt32(value); } else { cca = 0; } value = (xlRange.Cells[rCnt, CELL_POS_GROSS_SALARY] as Excel.Range).Value2; if (value == null) { gross_salary = 0; } else if (value.GetType().ToString() == prgsbrCntr.GetType().ToString()) { gross_salary = Convert.ToInt32(value); } else { gross_salary = 0; } value = (xlRange.Cells[rCnt, CELL_POS_INC_TAX] as Excel.Range).Value2; if (value == null) { inc_tax = 0; } else if (value.GetType().ToString() == prgsbrCntr.GetType().ToString()) { inc_tax = Convert.ToInt32(value); } else { inc_tax = 0; } value = (xlRange.Cells[rCnt, CELL_POS_PF_GPF] as Excel.Range).Value2; if (value == null) { pf_gpf = 0; } else if (value.GetType().ToString() == prgsbrCntr.GetType().ToString()) { pf_gpf = Convert.ToInt32(value); } else { pf_gpf = 0; } value = (xlRange.Cells[rCnt, CELL_POS_GPF_LOAN] as Excel.Range).Value2; if (value == null) { gpf_loan = 0; } else if (value.GetType().ToString() == prgsbrCntr.GetType().ToString()) { gpf_loan = Convert.ToInt32(value); } else { gpf_loan = 0; } value = (xlRange.Cells[rCnt, CELL_POS_GLIP] as Excel.Range).Value2; if (value == null) { glip = 0; } else if (value.GetType().ToString() == prgsbrCntr.GetType().ToString()) { glip = Convert.ToInt32(value); } else { glip = 0; } value = (xlRange.Cells[rCnt, CELL_POS_BANK_LOAN] as Excel.Range).Value2; if (value == null) { bank_loan = 0; } else if (value.GetType().ToString() == prgsbrCntr.GetType().ToString()) { bank_loan = Convert.ToInt32(value); } else { bank_loan = 0; } value = (xlRange.Cells[rCnt, CELL_POS_RECOVERY] as Excel.Range).Value2; if (value == null) { recovery = 0; } else if (value.GetType().ToString() == prgsbrCntr.GetType().ToString()) { recovery = Convert.ToInt32(value); } else { recovery = 0; } value = (xlRange.Cells[rCnt, CELL_POS_TOTAL_DEDUCT] as Excel.Range).Value2; if (value == null) { total_deduct = 0; } else if (value.GetType().ToString() == prgsbrCntr.GetType().ToString()) { total_deduct = Convert.ToInt32(value); } else { total_deduct = 0; } value = (xlRange.Cells[rCnt, CELL_POS_NET_SALARY] as Excel.Range).Value2; if (value == null) { net_salary = 0; } else if (value.GetType().ToString() == prgsbrCntr.GetType().ToString()) { net_salary = Convert.ToInt32(value); } else { net_salary = 0; } value = (xlRange.Cells[rCnt, CELL_POS_NPS] as Excel.Range).Value2; if (value == null) { nps = 0; } else if (value.GetType().ToString() == prgsbrCntr.GetType().ToString()) { nps = Convert.ToInt32(value); } else { nps = 0; } //gender = this.cmb_box_gender.SelectedItem.ToString(); //isPermanent = this.cmb_box_permanent.SelectedItem.ToString(); gender = this.cmb_box_gender.Text; isPermanent = this.cmb_box_permanent.Text; department = this.txtbx_src_file_path.Text; /* writefile content to file */ PdfDocument document = new PdfDocument(); PdfPage page = document.AddPage(); XGraphics gfx = XGraphics.FromPdfPage(page); XFont font = new XFont("Times New Roman", 11, XFontStyle.Regular); XFont headerFont = new XFont("Times New Roman", 20, XFontStyle.Underline); XTextFormatter tf = new XTextFormatter(gfx); gfx.DrawImage(image, 40, 40); fileContent = "SALARY CERTIFICATE\n"; //fileContent = fileContent + "------------------------------------"; XRect rect = new XRect(40, 200, 500, 40); gfx.DrawRectangle(XBrushes.White, rect); tf.Alignment = XParagraphAlignment.Center; tf.DrawString(fileContent, headerFont, XBrushes.Black, rect, XStringFormats.TopLeft); fileContent = " This is to certify that " + name + ","; fileContent = fileContent + " " + desig + ", dept. of " + department + ","; if (gender.Equals("MALE", StringComparison.OrdinalIgnoreCase)) { fileContent = fileContent + " is a " + isPermanent + " employee of this college.\n\n"; fileContent = fileContent + "Details of his salary for " + month + " as below:\n"; } else if (gender.Equals("FEMALE", StringComparison.OrdinalIgnoreCase)) { fileContent = fileContent + " is a " + isPermanent + " employee of this college.\n\n"; fileContent = fileContent + "Details of her salary for " + month + " as below:\n"; } else { fileContent = fileContent + " is a " + isPermanent + " employee of this college.\n\n"; fileContent = fileContent + "Details of his/her salary for " + month + " as below:\n"; } /* * print personal information first */ rect = new XRect(90, 240, 400, 40); gfx.DrawRectangle(XBrushes.White, rect); tf.Alignment = XParagraphAlignment.Justify; tf.DrawString(fileContent, font, XBrushes.Black, rect, XStringFormats.TopLeft); //fileContent = "Month : " + month + "\n\n"; /*fileContent = " EARNINGS\n"; * fileContent = fileContent + "-------------------------------------------\n";*/ fileContent = "\nBasic Pay" + "\nGrade Pay" + "\nD. A." + "\nH. R. A." + "\nC. C. A." + "\nOthers(FP)" + "\n\nGross Salary"; rect = new XRect(100, 310, 100, 120); gfx.DrawRectangle(XBrushes.White, rect); tf.Alignment = XParagraphAlignment.Left; tf.DrawString(fileContent, font, XBrushes.Black, rect, XStringFormats.TopLeft); fileContent = "\n : " + basic_pay.ToString() + "\n : " + grade_pay.ToString() + "\n : " + da.ToString() + "\n : " + hra.ToString() + "\n : " + cca.ToString() + "\n : " + other_fp.ToString() + "\n\n : " + gross_salary.ToString(); rect = new XRect(180, 310, 100, 120); gfx.DrawRectangle(XBrushes.White, rect); tf.Alignment = XParagraphAlignment.Left; tf.DrawString(fileContent, font, XBrushes.Black, rect, XStringFormats.TopLeft); ///*fileContent = "-------------------------------------------\n";*/ //fileContent = "\nGross Salary : " + gross_salary.ToString() + "\n"; ///*fileContent = fileContent + "-------------------------------------------\n\n";*/ //rect = new XRect(100, 420, 250, 40); //gfx.DrawRectangle(XBrushes.White, rect); //tf.Alignment = XParagraphAlignment.Left; //tf.DrawString(fileContent, font, XBrushes.Black, rect, XStringFormats.TopLeft); fileContent = "Deductions\n" + "nps\n" + "PF/GPF\n" + "GPF Loan\n" + "GLIP\n" + "Income Tax\n" + "Other\n\n" + "Total deductions"; rect = new XRect(330, 310, 100, 90); gfx.DrawRectangle(XBrushes.White, rect); tf.Alignment = XParagraphAlignment.Left; tf.DrawString(fileContent, font, XBrushes.Black, rect, XStringFormats.TopLeft); fileContent = "\n : " + nps.ToString() + "\n : " + pf_gpf.ToString() + "\n : " + gpf_loan.ToString() + "\n : " + glip.ToString() + "\n : " + inc_tax.ToString() + "\n : " + (bank_loan + recovery).ToString() + "\n\n : " + total_deduct.ToString(); rect = new XRect(410, 310, 100, 120); gfx.DrawRectangle(XBrushes.White, rect); tf.Alignment = XParagraphAlignment.Left; tf.DrawString(fileContent, font, XBrushes.Black, rect, XStringFormats.TopLeft); ////fileContent = "-------------------------------------------\n"; //fileContent = "\n Total Deduction : " + total_deduct.ToString() + "\n"; ////fileContent = fileContent + "-------------------------------------------\n\n"; //rect = new XRect(350, 420, 250, 40); //gfx.DrawRectangle(XBrushes.White, rect); //tf.Alignment = XParagraphAlignment.Left; //tf.DrawString(fileContent, font, XBrushes.Black, rect, XStringFormats.TopLeft); /*if (gender.Equals("MALE", StringComparison.OrdinalIgnoreCase)) * { * fileContent = "Note : He received Rs " + net_salary.ToString() + " after deduction, "; * } * else if (gender.Equals("FEMALE", StringComparison.OrdinalIgnoreCase)) * { * fileContent = "Note : She received Rs " + net_salary.ToString() + " after deduction, "; * } * else * { * fileContent = "Note : He/She received Rs " + net_salary.ToString() + " after deduction, "; * }*/ fileContent = "Note : Net salary Rs " + net_salary.ToString() + " after deduction, "; fileContent = fileContent + "for the month of : " + month + "\n"; rect = new XRect(90, 500, 400, 40); gfx.DrawRectangle(XBrushes.White, rect); tf.Alignment = XParagraphAlignment.Center; tf.DrawString(fileContent, font, XBrushes.Black, rect, XStringFormats.TopLeft); fileContent = "Date " + date_str + "\n\nAmount in Rs. "; rect = new XRect(410 /*40*/, 140 /*610*/, 100, 20); gfx.DrawRectangle(XBrushes.White, rect); tf.Alignment = XParagraphAlignment.Right; tf.DrawString(fileContent, font, XBrushes.Black, rect, XStringFormats.TopLeft); fileContent = "Principal"; rect = new XRect(450, 610, 100, 20); gfx.DrawRectangle(XBrushes.White, rect); tf.Alignment = XParagraphAlignment.Right; tf.DrawString(fileContent, font, XBrushes.Black, rect, XStringFormats.TopLeft); fileContent = "Accountant"; rect = new XRect(80, 610, 100, 20); gfx.DrawRectangle(XBrushes.White, rect); tf.Alignment = XParagraphAlignment.Left; tf.DrawString(fileContent, font, XBrushes.Black, rect, XStringFormats.TopLeft); fileContent = "Office\nSuperintendent"; rect = new XRect(250, 600, 100, 20); gfx.DrawRectangle(XBrushes.White, rect); tf.Alignment = XParagraphAlignment.Center; tf.DrawString(fileContent, font, XBrushes.Black, rect, XStringFormats.TopLeft); filepath = this.btn_dest_path.Text + indx.ToString() + "_" + name + "_" + this.cmb_box_month.SelectedItem.ToString() + "_SalarySlip" + ".pdf"; // Save the document... try { document.Save(filepath); MessageBox.Show("Salary slip is created for " + name + " whose PAN is " + pancard); } catch (Exception excp) { MessageBox.Show("Filename: " + filepath + " Cannot be saved.\n" + excp.Message + "\nTrying with no name", "Error in Saving Salary Slip.", MessageBoxButtons.OK, MessageBoxIcon.Error); filepath = this.btn_dest_path.Text + indx.ToString() + "_name_" + this.cmb_box_month.SelectedItem.ToString() + "_SalarySlip" + ".pdf"; try { document.Save(filepath); MessageBox.Show("Salary slip is created for " + name + " whose PAN is " + pancard); } catch (Exception excp2) { MessageBox.Show("Filename: " + filepath + " Cannot be saved again.\n" + excp2.Message + "\nCheck the out path", "Error in Saving Salary Slip.", MessageBoxButtons.OK, MessageBoxIcon.Error); } } document.Close(); break; /************************************************************************/ } this.prgsbr_mmh_slry_mkr.Value = this.prgsbr_mmh_slry_mkr.Maximum; /********************************************/ }
public LiteralNode(Float p_Value, PositionData p_PositionData) : base(NodeType.LITERAL, p_PositionData) { Value = p_Value; ValueType = p_Value.GetType(); }
static void Main(string[] args) { sbyte a1 = 1; System.SByte a2 = 1; byte b1 = 2; System.Byte b2 = 2; short c1 = 3; System.Int16 c2 = 3; ushort d1 = 4; System.UInt16 d2 = 4; int e1 = 5; System.Int32 e2 = 5; uint f1 = 6; System.UInt32 f2 = 6; long g1 = 7; System.Int64 g2 = 7; ulong h1 = 8; System.UInt64 h2 = 8; char i1 = 'a'; System.Char i2 = 'a'; float k1 = 10; System.Single k2 = 10; double l1 = 11; System.Double l2 = 11; bool m1 = true; System.Boolean m2 = true; decimal n1 = 12; System.Decimal n2 = 12; object o1 = new object { }; System.Object o2 = new object { }; string p1 = "Hello"; System.String p2 = "Hello"; Console.WriteLine(a1.GetType() + "\n" + a2.GetType() + "\n" + b1.GetType() + "\n" + b2.GetType() + "\n" + c1.GetType() + "\n" + c2.GetType() + "\n" + d1.GetType() + "\n" + d2.GetType() + "\n" + e1.GetType() + "\n" + e2.GetType() + "\n" + f1.GetType() + "\n" + f2.GetType() + "\n" + g1.GetType() + "\n" + g2.GetType() + "\n" + h1.GetType() + "\n" + h2.GetType() + "\n" + i1.GetType() + "\n" + i2.GetType() + "\n" + k1.GetType() + "\n" + k2.GetType() + "\n" + l1.GetType() + "\n" + l2.GetType() + "\n" + m1.GetType() + "\n" + m2.GetType() + "\n" + n1.GetType() + "\n" + n2.GetType() + "\n" + o1.GetType() + "\n" + o2.GetType() + "\n" + p1.GetType() + "\n" + p2.GetType() + "\n"); }
public Type GetType() { return(m_v.GetType()); }
static void Main(string[] args) { bool a = true; System.Boolean a1 = false; System.Type[] a2 = { a.GetType(), a1.GetType() }; foreach (var item in a2) { Console.Write(item.ToString() + "\n"); } byte b = 10; System.Byte b1 = 11; System.Type[] b2 = { b.GetType(), b1.GetType() }; foreach (var item in b2) { Console.Write(item.ToString() + "\n"); } sbyte c = 22; System.SByte c1 = 23; System.Type[] c2 = { c.GetType(), c1.GetType() }; foreach (var item in c2) { Console.Write(item.ToString() + "\n"); } short d = -33; System.Int16 d1 = -34; System.Type[] d2 = { d.GetType(), d1.GetType() }; foreach (var item in d2) { Console.Write(item.ToString() + "\n"); } ushort e = 33; System.UInt16 e1 = 34; System.Type[] e2 = { e.GetType(), e1.GetType() }; foreach (var item in e2) { Console.Write(item.ToString() + "\n"); } int f = 44; System.Int32 f1 = 45; System.Type[] f2 = { f.GetType(), f1.GetType() }; foreach (var item in f2) { Console.Write(item.ToString() + "\n"); } uint g = 55; System.UInt32 g1 = 56; System.Type[] g2 = { g.GetType(), g1.GetType() }; foreach (var item in g2) { Console.Write(item.ToString() + "\n"); } long h = -555; System.Int64 h1 = -556; System.Type[] h2 = { h.GetType(), h1.GetType() }; foreach (var item in h2) { Console.Write(item.ToString() + "\n"); } ulong i = 555; System.UInt64 i1 = 556; System.Type[] i2 = { i.GetType(), i1.GetType() }; foreach (var item in i2) { Console.Write(item.ToString() + "\n"); } float j = 666; System.Single j1 = 667; System.Type[] j2 = { j.GetType(), j1.GetType() }; foreach (var item in j2) { Console.Write(item.ToString() + "\n"); } double k = 777; System.Double k1 = 778; System.Type[] k2 = { k.GetType(), k1.GetType() }; foreach (var item in k2) { Console.Write(item.ToString() + "\n"); } decimal l = 888; System.Decimal l1 = 889; System.Type[] l2 = { l.GetType(), l1.GetType() }; foreach (var item in l2) { Console.Write(item.ToString() + "\n"); } char m = 'a'; System.Char m1 = 'b'; System.Type[] m2 = { m.GetType(), m1.GetType() }; foreach (var item in m2) { Console.Write(item.ToString() + "\n"); } string n = "Hello"; System.String n1 = "Bye"; System.Type[] n2 = { n.GetType(), n1.GetType() }; foreach (var item in n2) { Console.Write(item.ToString() + "\n"); } Console.ReadLine(); }
static void Main(string[] args) { /* * The object of this program is to ask the user to enter 7 grades for tests * and then the program will sum those grades and average them. */ //Declare and initialize variables Double dSum = 0.0; Double dAvg = 0.0; Double[] dGrades; String[] sNames; String sUserResp = String.Empty; Int32 iStudentCount = 0; //Determine number of students to have test scores Console.Write("How many students in the class? "); sUserResp = Console.ReadLine(); try { iStudentCount = Convert.ToInt32(sUserResp); } catch(Exception ex) { Console.WriteLine("I beg your pardon, fool. You have entered invalid data."); Console.WriteLine(ex.Message); Pause("Program will now exit."); return; } dGrades = new Double[iStudentCount]; sNames = new String[iStudentCount]; Type arrayType = dGrades.GetType(); if (arrayType.IsArray) { Pause("dGrades is an array of " + arrayType.ToString()); } else { Pause("dGrades is NOT an array."); } //Start loop for data entry for (Int32 i = 0; i < iStudentCount; i++) { //Obtain a student name Console.Write("Enter a name for student #" + (i + 1).ToString() + ": "); sNames.SetValue(Console.ReadLine(), i); //Obtain that student's grade Console.Write("Enter a grade for student #" + (i + 1).ToString() + ": "); sUserResp = Console.ReadLine(); try { dGrades.SetValue(Convert.ToDouble(sUserResp), i); } catch (Exception ex) { Console.WriteLine("I beg your pardon, fool. You have entered invalid data."); Console.WriteLine(ex.Message); Pause("Program will now exit."); return; } //Add this grade to the running sum dSum += dGrades[i]; } //Average the grades dAvg = dSum / (Double)iStudentCount; Console.WriteLine("\nHere is the breakdown of our student grades:"); for (Int32 i = 0; i < iStudentCount; i++) { Console.Write(sNames.GetValue(i) + ": "); Console.WriteLine(dGrades.GetValue(i).ToString()); } //Output the average Pause("The average score is: " + dAvg.ToString() + ".\nProgram will now exit."); }
static void Main(string[] args) { // объявляю все переменные двумя способами sbyte a1 = 1; System.SByte a2 = 2; short b1 = 3; System.Int16 b2 = 4; int c1 = 5; System.Int32 c2 = 6; long d1 = 7; System.Int64 d2 = 8; byte e1 = 9; System.Byte e2 = 10; ushort f1 = 11; System.UInt16 f2 = 12; uint g1 = 13; System.UInt32 g2 = 14; ulong h1 = 15; System.UInt64 h2 = 16; char i1 = 'A'; System.Char i2 = 'B'; float j1 = 17.1F; System.Single j2 = 17.2F; double k1 = 17.11; System.Double k2 = 17.22; bool l1 = false; System.Boolean l2 = true; decimal m1 = 1.1M; System.Decimal m2 = 2.2M; object n1 = 18; System.Object n2 = 19; string o1 = "Hi!"; System.String o2 = "Bye!"; //получаю типы этих переменных Type nameA1 = a1.GetType(); Type nameA2 = a2.GetType(); Type nameB1 = b1.GetType(); Type nameB2 = b2.GetType(); Type nameC1 = c1.GetType(); Type nameC2 = c2.GetType(); Type nameD1 = d1.GetType(); Type nameD2 = d2.GetType(); Type nameE1 = e1.GetType(); Type nameE2 = e2.GetType(); Type nameF1 = f1.GetType(); Type nameF2 = f2.GetType(); Type nameG1 = g1.GetType(); Type nameG2 = g2.GetType(); Type nameH1 = h1.GetType(); Type nameH2 = h2.GetType(); Type nameI1 = i1.GetType(); Type nameI2 = i2.GetType(); Type nameJ1 = j1.GetType(); Type nameJ2 = j2.GetType(); Type nameK1 = k1.GetType(); Type nameK2 = k2.GetType(); Type nameL1 = l1.GetType(); Type nameL2 = l2.GetType(); Type nameM1 = m1.GetType(); Type nameM2 = m2.GetType(); Type nameN1 = n1.GetType(); Type nameN2 = n2.GetType(); Type nameO1 = o1.GetType(); Type nameO2 = o2.GetType(); //вывожу типы переменных на консоль Console.WriteLine(nameA1); Console.WriteLine(nameA2); Console.WriteLine(nameB1); Console.WriteLine(nameB2); Console.WriteLine(nameC1); Console.WriteLine(nameC2); Console.WriteLine(nameD1); Console.WriteLine(nameD2); Console.WriteLine(nameE1); Console.WriteLine(nameE2); Console.WriteLine(nameF1); Console.WriteLine(nameF2); Console.WriteLine(nameG1); Console.WriteLine(nameG2); Console.WriteLine(nameH1); Console.WriteLine(nameH2); Console.WriteLine(nameI1); Console.WriteLine(nameI2); Console.WriteLine(nameJ1); Console.WriteLine(nameJ2); Console.WriteLine(nameK1); Console.WriteLine(nameK2); Console.WriteLine(nameL1); Console.WriteLine(nameL2); Console.WriteLine(nameM1); Console.WriteLine(nameM2); Console.WriteLine(nameN1); Console.WriteLine(nameN2); Console.WriteLine(nameO1); Console.WriteLine(nameO2); }
static void Main() { /* * prefix s - simple type, primitive type, built in type, value type * prefix f - .NET Framework type * * Numeric Types */ // signed 8 bit integer sbyte sByte = -128; System.SByte fByte = 127; // unsigned 8 bit integer byte sUnByte = 0; System.Byte fUnByte = 255; // signed 16 bit integer short sShort = -32768; System.Int16 fShort = 32767; // unsigned 16 bit integer ushort sUnShort = 0; System.UInt16 fUnShort = 65535; // signed 32 bit integer int sInt = -2147483648; System.Int32 fInt = 2_147_483_647; // unsigned 32 bit integer uint sUnInt = 0; System.UInt32 fUnInt = 4_294_967_295; // signed 64 bit integer long sLong = -9_223_372_036_854_775_808; System.Int64 fLong = 0x7FFFFFFFFFFFFFFF; // unsigned 64 bit integer ulong sUnLong = 0; System.UInt64 fUnLong = System.UInt64.MaxValue; // float 32 bit floating-point value (to initialize float use suffix 'f' or 'F') float sFloat = -3.5F; System.Single fFloat = 3.5f; // double 64 bit floating-point value double sDouble = System.Double.MinValue; System.Double fDouble = System.Double.MaxValue; // decimal 128 bit floating-point value (financial calculations)(use suffix m for real numbers) decimal sDecimal = 300.5m; System.Decimal fDecimal = 300; // character data type char sChar = 'a'; System.Char fChar = 'z'; // boolean type bool trueValue = true; bool falseValue = false; // default value for bool type // write to console Console.WriteLine("Type: {0}, Value: {1}", sByte.GetType(), sByte); Console.WriteLine("Type: {0}, Value: {1}", fByte.GetType(), fByte); Console.WriteLine("Type: {0}, Value: {1}", sUnByte.GetType(), sUnByte); Console.WriteLine("Type: {0}, Value: {1}", fUnByte.GetType(), fUnByte); Console.WriteLine("Type: {0}, Value: {1}", sShort.GetType(), sShort); Console.WriteLine("Type: {0}, Value: {1}", fShort.GetType(), fShort); Console.WriteLine("Type: {0}, Value: {1}", sUnShort.GetType(), sUnShort); Console.WriteLine("Type: {0}, Value: {1}", fUnShort.GetType(), fUnShort); Console.WriteLine("Type: {0}, Value: {1}", sInt.GetType(), sInt); Console.WriteLine("Type: {0}, Value: {1}", fInt.GetType(), fInt); Console.WriteLine("Type: {0}, Value: {1}", sUnInt.GetType(), sUnInt); Console.WriteLine("Type: {0}, Value: {1}", fUnInt.GetType(), fUnInt); Console.WriteLine("Type: {0}, Value: {1}", sLong.GetType(), sLong); Console.WriteLine("Type: {0}, Value: {1}", fLong.GetType(), fLong); Console.WriteLine("Type: {0}, Value: {1}", sUnLong.GetType(), sUnLong); Console.WriteLine("Type: {0}, Value: {1}", fUnLong.GetType(), fUnLong); Console.WriteLine("Type: {0}, Value: {1}", sFloat.GetType(), sFloat); Console.WriteLine("Type: {0}, Value: {1}", fFloat.GetType(), fFloat); Console.WriteLine("Type: {0}, Value: {1}", sDouble.GetType(), sDouble); Console.WriteLine("Type: {0}, Value: {1}", fDouble.GetType(), fDouble); Console.WriteLine("Type: {0}, Value: {1}", sDecimal.GetType(), sDecimal); Console.WriteLine("Type: {0}, Value: {1}", fDecimal.GetType(), fDecimal); Console.WriteLine("Type: {0}, Value: {1}", sChar.GetType(), sChar); Console.WriteLine("Type: {0}, Value: {1}", fChar.GetType(), fChar); Console.WriteLine("Type: {0}, Value: {1}", trueValue.GetType(), trueValue); Console.WriteLine("Type: {0}, Value: {1}", falseValue.GetType(), falseValue); // wait for user input to close the window Console.WriteLine(); Console.Write("Press any key to continue..."); Console.ReadKey(true); }