当前位置: 首页>>代码示例>>C#>>正文


C# Console.WriteLine方法代码示例

本文整理汇总了C#中Console.WriteLine方法的典型用法代码示例。如果您正苦于以下问题:C# Console.WriteLine方法的具体用法?C# Console.WriteLine怎么用?C# Console.WriteLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Console的用法示例。


在下文中一共展示了Console.WriteLine方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Button2_Click

        private void Button2_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();
            open.Filter = "Parts List File (*.list)|*.list";
            open.FileName = "";
            if (open.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
                return;
            System.IO.StreamReader read = new System.IO.StreamReader(open.FileName);
            open.Dispose();
            string str = read.ReadToEnd();

            Console c = new Console();
            //if (Convert.ToBoolean(Form1.AllocConsole()))
            //{
            c.WriteLine("Analyzing parts.list file...");
            if (Common.CheckPartList(str) == false)
            {
                return;
            }
            c.WriteLine("Successful. Importing parts.list...");
            Parts.Clear();
            Carbon.Properties.Settings.Default.PartList = str;
            Carbon.Properties.Settings.Default.Save();
            Parts = Common.LoadPartList(Carbon.Properties.Settings.Default.PartList);
            PartsListLoaded = true;
            c.WriteLine("Successful.");
            //Form1.FreeConsole();
            MessageBox.Show("Import was successful.");
        }
开发者ID:patrickb8man,项目名称:Carbon,代码行数:29,代码来源:Launcher.cs

示例2: CheckPartList


//.........这里部分代码省略.........
                                //Console.WriteLine("Found " + p3[0]);
                                name = p3[1];
                                npart.Name = p3[1];
                                break;
                            case "RawName":
                                //Console.WriteLine("Found " + p3[0]);
                                npart.RawName = p3[1];
                                break;
                            case "Thrust":
                                //Console.WriteLine("Found " + p3[0]);
                                npart.Thrust = Convert.ToDouble(p3[1]);
                                break;
                            case "ISP":
                                //Console.WriteLine("Found " + p3[0]);
                                npart.ISP = Convert.ToInt32(p3[1]);
                                break;
                            case "LiquidFuel":
                                //Console.WriteLine("Found " + p3[0]);
                                npart.LiquidFuel = Convert.ToDouble(p3[1]);
                                break;
                            case "SolidFuel":
                                //Console.WriteLine("Found " + p3[0]);
                                break;
                            case "XenonGas":
                                //Console.WriteLine("Found " + p3[0]);
                                break;
                            case "Oxidizer":
                                //Console.WriteLine("Found " + p3[0]);
                                npart.Oxidizer = Convert.ToDouble(p3[1]);
                                break;
                            case "MonoPropellant":
                                //Console.WriteLine("Found " + p3[0]);
                                npart.MonoPropellant = Convert.ToDouble(p3[1]);
                                break;
                            case "ElectricCharge":
                                //Console.WriteLine("Found " + p3[0]);
                                npart.Electricity = Convert.ToDouble(p3[1]);
                                break;
                            case "IntakeAir":
                                //Console.WriteLine("Found " + p3[0]);
                                break;
                            case "Mass":
                                //Console.WriteLine("Found " + p3[0]);
                                npart.Mass = Convert.ToDouble(p3[1]);
                                break;
                            case "DryMass":
                                //Console.WriteLine("Found " + p3[0]);
                                npart.DryMass = Convert.ToDouble(p3[1]);
                                break;
                            case "Cost":
                                //Console.WriteLine("Found " + p3[0]);
                                npart.Cost = Convert.ToInt32(p3[1]);
                                break;
                            case "IsEngine":
                                //Console.WriteLine("Found " + p3[0]);
                                npart.IsEngine = Convert.ToBoolean(p3[1]);
                                break;
                            case "IsAirEngine":
                                //Console.WriteLine("Found " + p3[0]);
                                npart.IsAirEngine = Convert.ToBoolean(p3[1]);
                                break;
                            case "IsIntake":
                                //Console.WriteLine("Found " + p3[0]);
                                npart.IsIntake = Convert.ToBoolean(p3[1]);
                                break;
                            case "IsDrainingElectricity":
                                //Console.WriteLine("Found " + p3[0]);
                                npart.IsDrainingElectricity = Convert.ToBoolean(p3[1]);
                                break;
                            case "ElectricityDrainRate":
                                //Console.WriteLine("Found " + p3[0]);
                                npart.ElectricityDrainRate = Convert.ToSingle(p3[1]);
                                break;
                            default:
                                if (ignorelist.Contains(p3[0]))
                                    continue;
                                Console.WriteLine("Found unknown string/value: " + p3[0]);
                                /*Console.WriteLine("Allow? (y/n)");
                                if (Console.ReadKey().KeyChar.ToString() == "y" | Console.ReadKey().KeyChar.ToString() == "Y")
                                {*/
                                    ignorelist = ignorelist + p3[0];
                                /*
                                }
                                else
                                {
                                    throw new Exception("Found unknown string/value");
                                } */
                                break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("Found Error: " + ex.Message + Environment.NewLine + "part.list file import failed");
                success = false;
            }
            Console.Hide();
            return success;
        }
开发者ID:patrickb8man,项目名称:Carbon,代码行数:101,代码来源:Common.cs


注:本文中的Console.WriteLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。