1 using System;
 2 using System.Collections.Generic;
 3 using System.IO;
 4 using System.Linq;
 5 using System.Text;
 6 using System.Threading.Tasks;
 7 
 8 namespace ConsoleApp8
 9 {
10     public class Class1
11     {
12         void DoIt()
13         {
14             //外侧片段 ctrl+k+s
15             if (File.Exists("E\\zm\\新建文本文档")) //另一种路径写法(@"E\zm\新建文本文档")
16             {
17                 FileStream aFile = new FileStream("E\\zm\\新建文本文档", FileMode.Open);
18                 Console.WriteLine(aFile.Length);
19                 aFile.Close(); //关闭文件流 using ...
20             }
21         }
22 
23         static void Main(string[] args)
24         {
25             //实例化class类 Class1 c = new(); 改.Net版本号
26             Class1 c = new Class1();
27         }
28     }
29     public static class class2
30     {
31         public static void Key(this string you) //拓展方法this
32         {
33             Console.WriteLine($"key{you}");//字符串
34             "ly".Key();
35         }
36     }
37 }

 

posted on 2024-04-09 00:50  ihoi  阅读(12)  评论(0)    收藏  举报