我在C#控制台应用程序中的缺失代码是什么?添加我的代码guyz ... [英] What is my Missing code in C# console application? add my code guyz...
本文介绍了我在C#控制台应用程序中的缺失代码是什么?添加我的代码guyz ...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string path = @"D:\try.txt";
Console.WriteLine("First Name:");
string firstname = string.Intern(Console.ReadLine());
string pin = string.Intern(Console.ReadLine());
CreateAcc p = new CreateAcc();
p.Firstname = firstname;
p.Pin = pin;
Console.WriteLine(p.code());
using (StreamWriter write = new StreamWriter(path))
{
write.WriteLine(p.Firstname);
}
}
}
//My new CLass
class CreateAcc
{
public CreateAcc() { }
private string firstname;
public string Firstname
{
get { return this.firstname; }
set { firstname = value; }
}
private string pin;
public string Pin
{
get { return this.pin; }
set { pin = value; }
}
public string code()
{
string code = "";
for (int i = 0; i < 10; i++)
{
return pin;
}
}
}
推荐答案
代码没有意义。当我对不正确的解决方案1发表评论时,(删除)......以下是一些问题:
The code makes no sense.As I put in my comment to the incorrect "Solution 1", (removed)…Here are some of the problems:
- 会员
pin
未声明或未显示; - 如果是,代码行带有
返回代码
永远不会到达,因为该方法会在第一次迭代中返回; - 使用代替
string.Empty
是不好的风格。
- The member
pin
is not declared or not shown; - if it was, the code line with "
return code
" would never reach, because the method would return in first iteration; - using "" instead of
string.Empty
is bad style.
另外,为 pin使用
是错的。 string
的想法
另请参阅我对该问题的评论。你有很多问题,但我认为这已经足够了。
我真的没有添加新课程的想法....
你可以帮助我把它改成课堂。?
static void Main(string [] args)
{
随机生成器=新的随机();
int Random = generator.Next(1032,2353);
Console.WriteLine(随机);
}
}
i really dont have an idea for adding new class....
can u help me for change this into a class.?
static void Main(string[] args)
{
Random generator = new Random();
int Random = generator.Next(1032, 2353);
Console.WriteLine(Random);
}
}
这篇关于我在C#控制台应用程序中的缺失代码是什么?添加我的代码guyz ...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文