如果那里的唯一代码是一个类,你将如何编写代码,将public添加到默认类中,就像这样
namespace HW2_2_Spaceship
{
public class Spaceship //added public to the default class
{
static void Main(string[] args)
{
}
Run Code Online (Sandbox Code Playgroud)
要么
namespace HW2_1_Book
{
class Book
{
static void Main(string[] args)
{
}
public class Book // added a new class with in the default class
{
Run Code Online (Sandbox Code Playgroud) 设计数据库以存储有关美国总统及其任期的详细信息.此外,记录他们的日期和出生地点,性别和政党关系的详细信息.你需要记录总统的顺序,以便确定任何总统的前任和继任者.请记住格罗弗克利夫兰有两个不连续的条款,政治背景可以改变.
这是我到目前为止让我知道如果可以改善这一点.我怎么能这样做"任何总统的前任和继任者都可以被识别"这是使用递归关系完成的,我将如何执行此操作?
Table President Table Origin
PK presID PK orID
presFName orCity
presLName orState
affiliation birthDate
gender
term
Run Code Online (Sandbox Code Playgroud) 我有3个子类"Staff,Faculty,Student",每个类从父类人员那里得到用户的第一个姓氏,这个id就像在运行控制台应用程序时添加4个随机数.我遇到的问题是所有的类都得到相同的4位数,我该如何解决这个问题,是的,必须使用随机我不能使用静态计数器.
Person.cs"父类"
public class Person
{
static string title;
protected string firstName;
protected string lastName;
protected string address;
protected string gender;
protected string dateOfBirth;
protected string userID;
protected Random rnd = new Random();
Run Code Online (Sandbox Code Playgroud)
Faculty.cs
namespace Person
{
public class Faculty : Person
{
public Faculty(string aTitle, string aFirstName, string aLastName, string aAddress,
string aGender, string aDateOfBirth)
: base(aTitle, aFirstName, aLastName, aAddress,
aGender, aDateOfBirth)
{
this.userID = firstName.Substring(0, 1) + lastName.Substring(0, 5);
this.userID = this.userID + rnd.Next(1000, 9999);
Console.WriteLine(this.userID);
}
} …Run Code Online (Sandbox Code Playgroud) 此代码验证 ISBN 是否有效。对于九位数字输入,我想通过计算和附加校验位来形成有效的 ISBN。对于少于九位数的输入,我希望它返回错误消息“请输入正确的数字”。我该怎么办?
public class isbn
{ //attributes
private string isbnNum;
//method
public string GetIsbn()
{
return this.isbnNum;
}
//constructor
public isbn()
{
Console.Write("Enter Your ISBN Number: ");
this.isbnNum = Console.ReadLine();
}//end default constructor
//method
public string displayISBN()
{
return this.GetIsbn();
}
public static void Main(string[] args)
{
//create a new instance of the ISBN/book class
isbn myFavoriteBook = new isbn();
//contains the method for checking validity
bool isValid = CheckDigit.CheckIsbn(myFavoriteBook.GetIsbn());
//print out the results of the validity.
Console.WriteLine(string.Format("Your …Run Code Online (Sandbox Code Playgroud)