| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1687 人关注过本帖
标题:[求助] 关于如何在代码中加入Console。ReadLine 这样运行程序后就不会马上消 ...
只看楼主 加入收藏
达文西
Rank: 1
等 级:新手上路
威 望:1
帖 子:117
专家分:0
注 册:2007-8-4
收藏
 问题点数:0 回复次数:6 
[求助] 关于如何在代码中加入Console。ReadLine 这样运行程序后就不会马上消失得问

Console.ReadLine;
应该加到哪 合适 斑竹等我得到这个帖子删除 没有技术含量


// keyword_class.cs
// class example
using System;
class Kid
{
private int age;
private string name;

// Default constructor:
public Kid()
{
name = "N/A";
}

// Constructor:
public Kid(string name, int age)
{
this.name = name;
this.age = age;
}

// Printing method:
public void PrintKid()
{
Console.WriteLine("{0}, {1} years old.", name, age);
}
}

class MainClass
{
static void Main()
{
// Create objects
// Objects must be created using the new operator:
Kid kid1 = new Kid("Craig", 11);
Kid kid2 = new Kid("Sally", 10);

// Create an object using the default constructor:
Kid kid3 = new Kid();

// Display results:
Console.Write("Kid#1:");
kid1.PrintKid();
Console.Write("Kid #2: ");
kid2.PrintKid();
Console.Write("Kid #3: ");
kid3.PrintKid();

}

}

搜索更多相关主题的帖子: Console ReadLine name age Kid 
2007-08-13 08:49
达文西
Rank: 1
等 级:新手上路
威 望:1
帖 子:117
专家分:0
注 册:2007-8-4
收藏
得分:0 

public static class TemperatureConverter
{
public static double CelsiusToFahrenheit(string temperatureCelsius)
{
// Convert argument to double for calculations.
double celsius = System.Double.Parse(temperatureCelsius);

// Convert Celsius to Fahrenheit.
double fahrenheit = (celsius * 9 / 5) + 32;

return fahrenheit;
}

public static double FahrenheitToCelsius(string temperatureFahrenheit)
{
// Convert argument to double for calculations.
double fahrenheit = System.Double.Parse(temperatureFahrenheit);

// Convert Fahrenheit to Celsius.
double celsius = (fahrenheit - 32) * 5 / 9;

return celsius;
}
}

class TestTemperatureConverter
{
static void Main()
{
System.Console.WriteLine("Please select the convertor direction");
System.Console.WriteLine("1. From Celsius to Fahrenheit.");
System.Console.WriteLine("2. From Fahrenheit to Celsius.");
System.Console.Write(":");

string selection = System.Console.ReadLine();
double F, C = 0;

switch (selection)
{
case "1":
System.Console.Write("Please enter the Celsius temperature: ");
F = TemperatureConverter.CelsiusToFahrenheit(System.Console.ReadLine());
System.Console.WriteLine("Temperature in Fahrenheit: {0:F2}", F);
break;

case "2":
System.Console.Write("Please enter the Fahrenheit temperature: ");
C = TemperatureConverter.FahrenheitToCelsius(System.Console.ReadLine());
System.Console.WriteLine("Temperature in Celsius: {0:F2}", C);
break;

default:
System.Console.WriteLine("Please select a convertor.");
break;
}
}
}


System.Console.WriteLine("Temperature in Celsius: {0:F2}", C);
0:F2}", c 这是什么意思呢

2007-08-13 09:46
达文西
Rank: 1
等 级:新手上路
威 望:1
帖 子:117
专家分:0
注 册:2007-8-4
收藏
得分:0 
假如第二个例子输入 摄氏负五度 会如何呢
又假如 输入-274度又会如何呢 实际上-274度根本不存在哦
2007-08-13 09:49
随风云
Rank: 1
等 级:新手上路
威 望:1
帖 子:263
专家分:0
注 册:2007-6-28
收藏
得分:0 
你加个console.readline就可以啦,我曾经用过的

真的想象风一样去流浪!
2007-08-13 10:01
达文西
Rank: 1
等 级:新手上路
威 望:1
帖 子:117
专家分:0
注 册:2007-8-4
收藏
得分:0 
我加了阿   加了  但是位置不对  系统老提示错误  
2007-08-13 10:18
师妃暄
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:805
专家分:107
注 册:2006-3-1
收藏
得分:0 
加到程序最后就行了

有实力才会有魅力 实力来自坚持不懈的努力
2007-08-13 10:23
随风云
Rank: 1
等 级:新手上路
威 望:1
帖 子:263
专家分:0
注 册:2007-6-28
收藏
得分:0 
恩,就是 我也是那样用的   

真的想象风一样去流浪!
2007-08-16 08:48
快速回复:[求助] 关于如何在代码中加入Console。ReadLine 这样运行程序后就不会 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014169 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved