当一个类中的唯一代码是如何编写代码时将public添加到默认类中
namespace HW2_2_Spaceship
{
public class Spaceship //added public to the default class
{
static void Main(string[] args)
{
}
或
namespace HW2_1_Book
{
class Book
{
static void Main(string[] args)
{
}
public class Book // added a new class with in the default class
{
答案 0 :(得分:6)
答案 1 :(得分:0)
//Program.cs, if u use visual studio then ensure you add
// the public access modifier yourself
namespace HW2_2_Spaceship
{
public class Program
{
public static void Main(string[] args)
{
//Do something here
}
}
}
//Book.cs, add the public modifier to the class
namespace HW2_2_Spaceship
{
public class Book
{
//add method and properties here
}
}