C#代码求救
发布网友
发布时间:2023-07-12 08:46
我来回答
共5个回答
热心网友
时间:2024-11-23 22:38
1.
public class Program
{
public static void Main(string[] args)
{
A a = new A();
A aa = new A("This is string");
A[] aaa = new A[5];
}
}
public class A
{
public object a;
public A()
{
Console.Write("A");
}
public A(string value)
{
Console.Write(value);
}
}
输出:
A
This is string
2.
public class MyMain:MyClass
{
public static void Main(string[] args)
{
MyClass myclass = new MyClass();
Console.Write(myclass.publicMember);
//Console.Write(myclass.protectedMember);出错
//Console.Write(myclass.privateMember);出错
myclass.publicMethod();
//myclass.privateMethod();出错
//myclass.protectedMethod();出错
}
}
public class MyClass
{
public string publicMember = "publicMember";
private string privateMember = "privateMember";
protected string protectedMember = "protectedMember";
public void publicMethod()
{
Console.Write("public Method");
}
private void privateMethod()
{
Console.Write("private Method");
}
protected void protectedMethod()
{
Console.Write("protected Method");
}
}
3.
public class MyClass
{
protected string protectedMember = "protectedMember";
public string protectedMethod()
{
return this.protectedMember;
}
}
public class MyClass1
{
public void GetValue()
{
MyClass myClass = new MyClass();
Console.Write(myClass.protectedMethod());
}
}
4.
public class MyMain
{
public static void Main(string[] args)
{
string inputText = "a is first Letter";
Console.WriteLine(inputText.IndexOf("a"));
inputText = inputText.Insert(3, "Hello");
Console.WriteLine(inputText);
inputText = inputText.Replace("Hello", "Me");
Console.WriteLine(inputText);
string[] str = inputText.Split('M');
for (int i = 0; i < str.Length; i++)
{
Console.WriteLine(str[i]);
}
}
}
热心网友
时间:2024-11-23 22:38
哎.总之辛苦了,我们那老师白痴 的.不会教.搞得全班都不会.所以发动全班就找答案咯
热心网友
时间:2024-11-23 22:39
没价值!!!!!!!!!!!!!!!!!
热心网友
时间:2024-11-23 22:39
你不自己思考,弄写答案有意思吗?
小伙子学习是你自己的
热心网友
时间:2024-11-23 22:40
这些东西很基础,自己看看书就做出来了.