Product.cs

1234567891011121314151617181920212223242526272829303132
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HelloCSharp { class Product { private string name; private string thumbnail; private int price; private int shipCost; private string[] materials; private string introduce; private string description; protected int serialNumber; public Product() { } public Product(int _s) { serialNumber = _s; } public int SerialNumber { get => serialNumber; } } }

Phone.cs

123456789101112131415161718192021222324252627282930313233
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HelloCSharp { struct Color { byte r; byte g; byte b; } class Phone : Product { string imei; Color color; /* public Phone(int _s) : base(_s) { } */ public Phone(int _s) { serialNumber = _s; } } }

Laptop.cs

1234567891011121314
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HelloCSharp { class Laptop : Product { public Laptop(int _s) : base(_s) { }

Program.cs

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; using Stdio; namespace HelloCSharp { class Program { static void Main(string[] args) { Phone[] phones = new Phone[10]; Laptop[] laptops = new Laptop[10]; for (int i = 0; i < phones.Length; i++) { phones[i] = new Phone(0 + i); } for (int i = 0; i < laptops.Length; i++) { laptops[i] = new Laptop(100 + i); } int productSerialNumber = 3; for (int i = 0; i < phones.Length; i++) { if (productSerialNumber == phones[i].SerialNumber) { } } for (int i = 0; i < laptops.Length; i++) { if (productSerialNumber == laptops[i].SerialNumber) { } } Console.ReadLine(); } } }