1、c#中的访问修饰符 public :公开的公共的 private:私有的,只能在当前类的内部访问 protected:受保护的,只能在当前类的内部以及该类的子类中访问。 internal:只能在当前项目中访问。在同一个项目中,internal和public的权限是一样。 protected internal:protected+internal
1)、能够修饰类的访问修饰符只有两个:public、internal。 2)、可访问性不一致。 子类的访问权限不能高于父类的访问权限,会暴漏父类的成员。
2、设计模式 设计这个项目的一种方式。
3、简单工厂设计模式
4、值类型在复制的时候,传递的是这个值得本身。 引用类型在复制的时候,传递的是对这个对象的引用。 5、序列化:就是将对象转换为二进制 反序列化:就是将二进制转换为对象 作用:传输数据。 序列化: 1)、将这个类标记为可以被序列化的。 6、partial部分类
7、sealed密封类 不能够被其他类继承,但是可以继承于其他类。
8、接口 [public] interface I..able { 成员; }
接口是一种规范。 只要一个类继承了一个接口,这个类就必须实现这个接口中所有的成员
为了多态。 接口不能被实例化。 也就是说,接口不能new(不能创建对象)
接口中的成员不能加“访问修饰符”,接口中的成员访问修饰符为public,不能修改。
(默认为public) 接口中的成员不能有任何实现(“光说不做”,只是定义了一组未实现的成员)。
接口中只能有方法、属性、索引器、事件,不能有“字段”和构造函数。
接口与接口之间可以继承,并且可以多继承。
接口并不能去继承一个类,而类可以继承接口 (接口只能继承于接口,而类既可以继承接口,也可以继承类)
实现接口的子类必须实现该接口的全部成员。
一个类可以同时继承一个类并实现多个接口,如果一个子类同时继承了父类A,并实现了接口IA,那么语法上A必须写在IA的前面。
class MyClass:A,IA{},因为类是单继承的。
显示实现接口的目的:解决方法的重名问题 什么时候显示的去实现接口: 当继承的借口中的方法和参数一摸一样的时候,要是用显示的实现接口
当一个抽象类实现接口的时候,需要子类去实现接口。
01复习
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace _01复习
{
class Program
{
static void Main(string[] args)
{
/*
泛型集合
* List<T>
* Dictionary<T,T>
* 装箱和拆箱
* 装箱:将值类型转换为引用类型
* 拆箱:将引用类型转换为值类型
* 我们应该尽量避免在代码中发生装箱或者拆箱
* 文件流
* FileStream StreamReader和StreamWriter
* 多态:虚方法、
* //抽象类、接口
* 虚方法:
* 抽象类:
*/
List<int> list = new List<int>();
//Dictionary<int, string> dic = new Dictionary<int, string>();
//dic.Add(1, "张三");
//dic[2] = "李四";
//foreach (KeyValuePair<int,string> kv in dic)
//{
// Console.WriteLine("{0}-----{1}",kv.Key,kv.Value);
//}
//Console.ReadKey();
//File FileStream StreamReader StreamWriter
//using (FileStream fsRead = new FileStream("0505远程版机器码.txt", FileMode.OpenOrCreate, FileAccess.Read))
//{
// byte[] buffer = new byte[1024 * 1024 * 5];
// //本次读取实际读取到的字节数
// int r = fsRead.Read(buffer, 0, buffer.Length);
// //将字节数组中的每个元素按照我们指定的编码格式解析成字符串
// string s = Encoding.Default.GetString(buffer, 0, r);
// Console.WriteLine(s);
//}
//Console.ReadKey();
using (FileStream fsWrite = new FileStream(@"new.txt", FileMode.OpenOrCreate, FileAccess.Write))
{
string s = "abc";
byte[] buffer = Encoding.UTF8.GetBytes(s);
fsWrite.Write(buffer, 0, buffer.Length);
}
Console.WriteLine("OK");
Console.ReadKey();
//虚方法和抽象类
//老师可以起立 学生也可以起立 校长也可以起立
//声明父类去指定子类对象
Person p = new HeadMaster();//new Teacher();//new Student();
p.StandUp();
Console.ReadKey();
}
}
public abstract class Person
{
public abstract void StandUp();
}
public class Student : Person
{
public override void StandUp()
{
Console.WriteLine("学生起立,说老师好");
}
}
public class Teacher : Person
{
public override void StandUp()
{
Console.WriteLine("老师起立,说校长好");
}
}
public class HeadMaster : Person
{
public override void StandUp()
{
Console.WriteLine("校长起来说领导好");
}
}
}
02访问修饰符
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _02访问修饰符
{
class Program
{
static void Main(string[] args)
{
Person p = new Person();
}
}
public class Person
{
//protected string _name;
//public int _age;
//private char _gender;
//internal int _chinese;
//protected internal int _math;
}
public class Student : Person
{
}
//public class Student:Person
//{
//}
}
03简单工厂设计模式
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _03简单工厂设计模式
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入您想要的笔记本品牌");
string brand = Console.ReadLine();
NoteBook nb = GetNoteBook(brand);
nb.SayHello();
Console.ReadKey();
}
/// <summary>
/// 简单工厂的核心 根据用户的输入创建对象赋值给父类
/// </summary>
/// <param name="brand"></param>
/// <returns></returns>
public static NoteBook GetNoteBook(string brand)
{
NoteBook nb = null;
switch (brand)
{
case "Lenovo": nb = new Lenovo();
break;
case "IBM": nb = new IBM();
break;
case "Acer": nb = new Acer();
break;
case "Dell": nb = new Dell();
break;
}
return nb;
}
}
public abstract class NoteBook
{
public abstract void SayHello();
}
public class Lenovo : NoteBook
{
public override void SayHello()
{
Console.WriteLine("我是联想笔记本,你联想也别想");
}
}
public class Acer : NoteBook
{
public override void SayHello()
{
Console.WriteLine("我是鸿基笔记本");
}
}
public class Dell : NoteBook
{
public override void SayHello()
{
Console.WriteLine("我是戴尔笔记本");
}
}
public class IBM : NoteBook
{
public override void SayHello()
{
Console.WriteLine("我是IBM笔记本");
}
}
}
04值类型和引用类型
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _04值类型和引用类型
{
class Program
{
static void Main(string[] args)
{
//值类型:int double char decimal bool enum struct
//引用类型:string 数组 自定义类 集合 object 接口
//值传递和引用传递
//int n1 = 10;
//int n2 = n1;
//n2 = 20;
//Console.WriteLine(n1);
//Console.WriteLine(n2);
//Console.ReadKey();
//Person p1 = new Person();
//p1.Name = "张三";
//Person p2 = p1;
//p2.Name = "李四";
//Console.WriteLine(p1.Name);
//Console.ReadKey();
//Person p = new Person();
//p.Name = "张三";
//Test(p);
//Console.WriteLine(p.Name);
//Console.ReadKey();
string s1 = "张三";
string s2 = s1;
s2 = "李四";
Console.WriteLine(s1);
Console.WriteLine(s2);
Console.ReadKey();
int number = 10;
TestTwo(ref number);
Console.WriteLine(number);
Console.ReadKey();
}
//int n=number;
public static void TestTwo(ref int n)
{
n += 10;
}
//Person pp=p;
public static void Test(Person pp)
{
Person p = pp;
p.Name = "李四";
}
}
public class Person
{
private string _name;
public string Name
{
get { return _name; }
set { _name = value; }
}
}
}
05序列化和反序列化
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
namespace _05序列化和反序列化
{
class Program
{
static void Main(string[] args)
{
//要将p这个对象 传输给对方电脑
//Person p = new Person();
//p.Name = "张三";
//p.Age = 19;
//p.Gender = '男';
//using (FileStream fsWrite = new FileStream(@"C:\Users\SpringRain\Desktop\111.txt", FileMode.OpenOrCreate, FileAccess.Write))
//{
// //开始序列化对象
// BinaryFormatter bf = new BinaryFormatter();
// bf.Serialize(fsWrite, p);
//}
//Console.WriteLine("序列化成功");
//Console.ReadKey();
//接收对方发送过来的二进制 反序列化成对象
Person p;
using (FileStream fsRead = new FileStream(@"C:\Users\SpringRain\Desktop\111.txt", FileMode.OpenOrCreate, FileAccess.Read))
{
BinaryFormatter bf = new BinaryFormatter();
p = (Person)bf.Deserialize(fsRead);
}
Console.WriteLine(p.Name);
Console.WriteLine(p.Age);
Console.WriteLine(p.Gender);
Console.ReadKey();
}
}
[Serializable]
public class Person
{
private string _name;
public string Name
{
get { return _name; }
set { _name = value; }
}
private char _gender;
public char Gender
{
get { return _gender; }
set { _gender = value; }
}
private int _age;
public int Age
{
get { return _age; }
set { _age = value; }
}
}
}
06部分类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _06部分类
{
class Program
{
static void Main(string[] args)
{
}
}
public partial class Person
{
private string _name;
public void Test()
{
}
}
public partial class Person
{
public void Test(string name)
{
// _name
}
}
}
07密封类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _07密封类
{
class Program
{
static void Main(string[] args)
{
}
}
public sealed class Person:Test
{
}
public class Test
{
}
}
08重写ToString()方法
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _08重写ToString__方法
{
class Program
{
static void Main(string[] args)
{
Person p = new Person();
Console.WriteLine(p.ToString());
Console.ReadKey();
}
}
public class Person
{
public override string ToString()
{
return "Hello World";
}
}
}
09接口
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _09接口
{
class Program
{
static void Main(string[] args)
{
//接口就是一个规范、能力。
}
}
public class Person
{
public void CHLSS()
{
Console.WriteLine("我是人类,我可以吃喝拉撒睡");
}
}
public class NBAPlayer
{
public void KouLan()
{
Console.WriteLine("我可以扣篮");
}
}
public class Student : Person,IKouLanable
{
public void KouLan()
{
Console.WriteLine("我也可以扣篮");
}
}
public interface IKouLanable
{
void KouLan();
}
}
10接口的语法特征
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _10接口的语法特征
{
class Program
{
static void Main(string[] args)
{
}
}
public interface IFlyable
{
//接口中的成员不允许添加访问修饰符 ,默认就是public
void Fly();
string Test();
//不允许写具有方法体的函数
// string _name;
string Name
{
get;
set;
}
}
}
11、自动属性和普通属性
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _11_自动属性和普通属性
{
class Program
{
static void Main(string[] args)
{
}
}
public class Person
{
private string _name;
public string Name
{
get { return _name; }
set { _name = value; }
}
/// <summary>
/// 自动属性
/// </summary>
public int Age
{
get;
set;
}
}
}
12接口特点
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _12接口特点
{
class Program
{
static void Main(string[] args)
{
IFlyable fly = new Bird();//new Person();// new IFlyable();
fly.Fly();
Console.ReadKey();
}
}
public class Person:IFlyable
{
public void Fly()
{
Console.WriteLine("人类在飞");
}
}
public class Student:Person, IFlyable
{
public void Fly()
{
Console.WriteLine("人类在飞");
}
}
public class Bird : IFlyable
{
public void Fly()
{
Console.WriteLine("鸟在飞");
}
}
public interface IFlyable
{
//不允许有访问修饰符 默认为public
//方法、自动属性
void Fly();
}
public interface M1
{
void Test1();
}
public interface M2
{
void Test2();
}
public interface M3
{
void Test3();
}
public interface SupperInterface : M1, M2, M3
{
}
public class Car : SupperInterface
{
public void Test1()
{
throw new NotImplementedException();
}
public void Test2()
{
throw new NotImplementedException();
}
public void Test3()
{
throw new NotImplementedException();
}
}
}
13接口练习
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _13接口练习
{
class Program
{
static void Main(string[] args)
{
//麻雀会飞 鹦鹉会飞 鸵鸟不会飞 企鹅不会飞 直升飞机会飞
//用多态来实现
//需方法、抽象类、接口
IFlyable fly = new Plane();//new MaQue();//new YingWu();
fly.Fly();
Console.ReadKey();
}
}
public class Bird
{
public double Wings
{
get;
set;
}
public void EatAndDrink()
{
Console.WriteLine("我会吃喝");
}
}
public class MaQue : Bird,IFlyable
{
public void Fly()
{
Console.WriteLine("麻雀会飞");
}
}
public class YingWu : Bird, IFlyable,ISpeak
{
public void Fly()
{
Console.WriteLine("鹦鹉会飞");
}
public void Speak()
{
Console.WriteLine("鹦鹉可以学习人类说话");
}
}
public class TuoBird : Bird
{
}
public class QQ : Bird
{
}
public class Plane : IFlyable
{
public void Fly()
{
Console.WriteLine("直升飞机转动螺旋桨飞行");
}
}
public interface IFlyable
{
void Fly();
}
public interface ISpeak
{
void Speak();
}
}
14、显示实现接口
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _14_显示实现接口
{
class Program
{
static void Main(string[] args)
{
//显示实现接口就是为了解决方法的重名问题
IFlyable fly = new Bird();
fly.Fly();
Bird bird = new Bird();
bird.Fly();
Console.ReadKey();
}
}
public class Bird : IFlyable
{
public void Fly()
{
Console.WriteLine("鸟飞会");
}
/// <summary>
/// 显示实现接口
/// </summary>
// void IFlyable.Fly()
//{
// Console.WriteLine("我是接口的飞");
//}
}
public interface IFlyable
{
void Fly();
}
}
15、总结
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _15_总结
{
class Program
{
static void Main(string[] args)
{
//什么时候用虚方法来实现多态?
//什么使用用抽象类来实现多态?
//什么时候用接口来实现多态?
//真的鸭子会游泳 木头鸭子不会游泳 橡皮鸭子会游泳
ISwimming swim = new XPDuck();//new RealDuck();
swim.Swim();
RealDuck rd = new RealDuck();
rd.Swim();
RealDuck xd = new XPDuck();
xd.Swim();
Console.ReadKey();
}
}
public class RealDuck:ISwimming
{
public virtual void Swim()
{
Console.WriteLine("真的鸭子靠翅膀游泳");
}
}
public class MuDuck
{
}
public class XPDuck : RealDuck, ISwimming
{
public override void Swim()
{
Console.WriteLine("橡皮鸭子飘着游泳");
}
}
public interface ISwimming
{
void Swim();
}
}
16超市收银系统
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _16超市收银系统
{
class Acer:ProductFather
{
public Acer(string id, double price, string Name)
: base(id, price, Name)
{
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _16超市收银系统
{
class Banana : ProductFather
{
public Banana(string id, double price, string Name)
: base(id, price, Name)
{
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _16超市收银系统
{
/// <summary>
/// 打折的父类
/// </summary>
abstract class CalFather
{
/// <summary>
/// 计算打折后应付多少钱
/// </summary>
/// <param name="realMoney">打折前应付的价钱</param>
/// <returns>打折后应付的前</returns>
public abstract double GetTotalMoney(double realMoney);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _16超市收银系统
{
/// <summary>
/// 买M元 送N元
/// </summary>
class CalMN:CalFather
{
//买500送100
public double M
{
get;
set;
}
public double N
{
get;
set;
}
public CalMN(double m, double n)
{
this.M = m;
this.N = n;
}
public override double GetTotalMoney(double realMoney)
{
//600 -100
//1000-200
//1200
if (realMoney >= this.M)
{
return realMoney - (int)(realMoney / this.M) * this.N;
}
else
{
return realMoney;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _16超市收银系统
{
/// <summary>
/// 不打折 该多少钱就多少钱
/// </summary>
class CalNormal:CalFather
{
public override double GetTotalMoney(double realMoney)
{
return realMoney;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _16超市收银系统
{
/// <summary>
/// 按折扣率打折
/// </summary>
class CalRate:CalFather
{
/// <summary>
/// 折扣率
/// </summary>
public double Rate
{
get;
set;
}
public CalRate(double rate)
{
this.Rate = rate;
}
public override double GetTotalMoney(double realMoney)
{
return realMoney * this.Rate;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _16超市收银系统
{
class CangKu
{
List<List<ProductFather>> list = new List<List<ProductFather>>();
/// <summary>
///向用户展示货物
/// </summary>
public void ShowPros()
{
foreach (var item in list)
{
Console.WriteLine("我们超市有:" + item[0].Name + "," + "\t" + "有" + item.Count + "个," + "\t" + "每个" + item[0].Price + "元");
}
}
//list[0]存储Acer电脑
//list[1]存储三星手机
//list[2]存储酱油
//list[3]存储香蕉
/// <summary>
/// 在创建仓库对象的时候 像仓库中添加货架
/// </summary>
public CangKu()
{
list.Add(new List<ProductFather>());
list.Add(new List<ProductFather>());
list.Add(new List<ProductFather>());
list.Add(new List<ProductFather>());
}
/// <summary>
/// 进货
/// </summary>
/// <param name="strType">货物的类型</param>
/// <param name="count">货物的数量</param>
public void JinPros(string strType, int count)
{
for (int i = 0; i < count; i++)
{
switch (strType)
{
case "Acer": list[0].Add(new Acer(Guid.NewGuid().ToString(), 1000, "宏基笔记本"));
break;
case "SamSung": list[1].Add(new SamSung(Guid.NewGuid().ToString(), 2000, "棒之手机"));
break;
case "JiangYou": list[2].Add(new JiangYou(Guid.NewGuid().ToString(), 10, "老抽酱油"));
break;
case "Banana": list[3].Add(new Banana(Guid.NewGuid().ToString(), 50, "大香蕉"));
break;
}
}
}
/// <summary>
/// 从仓库中提取货物
/// </summary>
/// <param name="strType"></param>
/// <param name="count"></param>
/// <returns></returns>
public ProductFather[] QuPros(string strType, int count)
{
ProductFather[] pros = new ProductFather[count];
for (int i = 0; i < pros.Length; i++)
{
switch (strType)
{
case "Acer":
pros[i] = list[0][0];
list[0].RemoveAt(0);
break;
case "SamSung": pros[i] = list[1][0];
list[1].RemoveAt(0);
break;
case "JiangYou": pros[i] = list[2][0];
list[2].RemoveAt(0);
break;
case "Banana": pros[i] = list[3][0];
list[3].RemoveAt(0);
break;
}
}
return pros;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _16超市收银系统
{
class JiangYou:ProductFather
{
public JiangYou(string id, double price, string Name)
: base(id, price, Name)
{
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _16超市收银系统
{
class ProductFather
{
public double Price
{
get;
set;
}
public string Name
{
get;
set;
}
public string ID
{
get;
set;
}
public ProductFather(string id, double price, string Name)
{
this.ID = id;
this.Price = price;
this.Name = Name;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _16超市收银系统
{
class ProductFather
{
public double Price
{
get;
set;
}
public string Name
{
get;
set;
}
public string ID
{
get;
set;
}
public ProductFather(string id, double price, string Name)
{
this.ID = id;
this.Price = price;
this.Name = Name;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _16超市收银系统
{
class Program
{
static void Main(string[] args)
{
//创建超市对象
SupperMarket sm = new SupperMarket();
//展示货物
sm.ShowPros();
//跟用户交互
sm.AskBuying();
Console.ReadKey();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _16超市收银系统
{
class SamSung:ProductFather
{
public SamSung(string id, double price, string Name)
: base(id, price, Name)
{
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _16超市收银系统
{
class SupperMarket
{
//创建仓库对象
CangKu ck = new CangKu();
/// <summary>
/// 创建超市对象的时候,给仓库的货架上导入货物
/// </summary>
public SupperMarket()
{
ck.JinPros("Acer", 1000);
ck.JinPros("SamSung", 1000);
ck.JinPros("JiangYou", 1000);
ck.JinPros("Banana", 1000);
}
/// <summary>
/// 跟用户交互的过程
/// </summary>
public void AskBuying()
{
Console.WriteLine("欢迎观临,请问您需要些什么?");
Console.WriteLine("我们有 Acer、SamSung、Jiangyou、Banana");
string strType = Console.ReadLine();
Console.WriteLine("您需要多少?");
int count = Convert.ToInt32(Console.ReadLine());
//去仓库取货物
ProductFather[] pros = ck.QuPros(strType, count);
//下面该计算价钱了
double realMoney = GetMoney(pros);
Console.WriteLine("您总共应付{0}元", realMoney);
Console.WriteLine("请选择您的打折方式 1--不打折 2--打九折 3--打85 折 4--买300送50 5--买500送100");
string input = Console.ReadLine();
//通过简单工厂的设计模式根据用户的舒服获得一个打折对象
CalFather cal = GetCal(input);
double totalMoney = cal.GetTotalMoney(realMoney);
Console.WriteLine("打完折后,您应付{0}元", totalMoney);
Console.WriteLine("以下是您的购物信息");
foreach (var item in pros)
{
Console.WriteLine("货物名称:"+item.Name+","+"\t"+"货物单价:"+item.Price+","+"\t"+"货物编号:"+item.ID);
}
}
/// <summary>
/// 根据用户的选择打折方式返回一个打折对象
/// </summary>
/// <param name="input">用户的选择</param>
/// <returns>返回的父类对象 但是里面装的是子类对象</returns>
public CalFather GetCal(string input)
{
CalFather cal = null;
switch (input)
{
case "1": cal = new CalNormal();
break;
case "2": cal = new CalRate(0.9);
break;
case "3": cal = new CalRate(0.85);
break;
case "4": cal = new CalMN(300, 50);
break;
case "5": cal = new CalMN(500, 100);
break;
}
return cal;
}
/// <summary>
/// 根据用户买的货物计算总价钱
/// </summary>
/// <param name="pros"></param>
/// <returns></returns>
public double GetMoney(ProductFather[] pros)
{
double realMoney = 0;
//realMoney = pros[0].Price * pros.Length;
for (int i = 0; i < pros.Length; i++)
{
realMoney += pros[i].Price;
// realMoney = pros[i] * pros.Length;
}
return realMoney;
}
public void ShowPros()
{
ck.ShowPros();
}
}
}
17GUID
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _17GUID
{
class Program
{
static void Main(string[] args)
{
//产生一个不会重复的编号
Console.WriteLine(Guid.NewGuid().ToString());
Console.WriteLine(Guid.NewGuid().ToString());
Console.WriteLine(Guid.NewGuid().ToString());
Console.WriteLine(Guid.NewGuid().ToString());
Console.WriteLine(Guid.NewGuid().ToString());
Console.ReadKey();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _17GUID
{
class SamSung
{
}
}