C#從入門到精通(5)

? ?

目錄

第十二章 其他基礎知識

(1)抽象類和方法

(2)接口

(3)集合與索引器

(4)委托和匿名方法

(5)事件

(6)迭代器

(7)分部類

(8)泛型

第十三章 文件操作

(1)基本知識

(2)判斷文件是否存在

(3)創建文件

(4)復制文件

(5)移動文件

(6)刪除文件

(7)獲取文件信息

第十四章 文件夾操作

(1)Directory與DirectoryInfo類

(2)判斷文件夾是否存在

(3)創建文件夾? ??

(4)移動文件夾

(5)刪除文件夾

(6)遍歷文件夾

第十五章 流操作類

(1)流操作

(2)流的類型

(3)文件流

(4)對文件內容進行操作

(5)文本文件的讀寫


? ? 學習視頻——C#從入門到精通(第六版)_嗶哩嗶哩_bilibili

第十二章 其他基礎知識

(1)抽象類和方法

? ? ? ? 如果一個類不與具體的事物相聯系,而只表達一種抽象的概念或行為,僅僅作為其派生類的一個基類,這樣的類就可以聲明為抽象類,在抽象類中聲明方法時,如果加上abstract關鍵字,則為抽象方法,抽象方法不提供具體實現。例如

public abstract class test
{public abstract void method();
}

示例

  public abstract class Vehicle{public string name {  get; set; }public abstract void move();}public class Car:Vehicle{public override void move(){Console.WriteLine("{0}在公路上形式",name);}}public class Train:Vehicle{public override void move() { Console.WriteLine("{0}在鐵路上行駛",name); }}
(2)接口

? ? ? ? 接口提出了一種規范,讓使用接口的程序設計人員必須嚴格遵守接口的約定。接口可以包含屬性、方法、索引器和事件,但不能包含這些成員的具體值,只能進行定義。

? ? ? ? C#聲明接口時,使用interface關鍵字。

? ? ? ?修飾符 interface 接口名稱:繼承的接口列表

? ? ? ? {

? ? ? ? ????????接口內容:

????????}

? ? ? ? 1.接口的實現與繼承

? ? ? ? 定義:

 public interface information{string Code { get; set; }void showInfo();}

? ? ? ? 實現:

  public class Info : information{string code = "";public string Code{get{return code;}set{code = value;}}public void showInfo(){Console.WriteLine(code);}}

2.顯式接口成員實現

? ? ? ? 如果類實現兩個接口,并且這兩個接口包含相同簽名的成員,那么在類中實現該成員將導致兩個接口都是用該成員作為它們的實現。如果兩個接口有不同的功能。會導致其中一個發生錯誤。這時可以顯式實現該接口成員,即創建一個僅通過該接口調用并且特定于該接口的類成員。顯式接口的實現是通過使用接口名稱和一個句號命名該類成員實現的。示例

 interface information{string Code { get; set; }void showInfo();}interface information2{string Code { get; set; }void showInfo();}public class Info : information,information2{string code = "";string information.Code{get{return code;}set{code = value;}}void information.showInfo(){Console.WriteLine(code);}string information2.Code{get{return code;}set{code = value;}}void information2.showInfo(){Console.WriteLine(code+"11111");}}

? ? ? ? 調用的時候根據創建的接口調用對應的屬性和方法。

(3)集合與索引器

? ? ? ? 集合類似于數組,是一組組合在一起的類型化對象,可以通過遍歷獲取其中的每個元素。例如ArrayList集合是一種非泛型集合類,動態添加刪除元素。ArrayList相當于一個高級的動態數組。但并不等同于數組。示例

ArrayList list = new ArrayList();
list.Add("張三");
list.Add("李四");
list.Add("王五");
foreach(string name in list) 
{Console.WriteLine(name);
}

? ? ? ? 索引器——C#支持一種名為索引器的特殊屬性,它能通過引用數組元素的方式來引用對象。

語法:修飾符? 類型? this [參數列表]{ get {get 訪問器體}? ? set{set 訪問器體} }

示例

 static void Main(string[] args){CollClass collClass = new CollClass();collClass[0] = "張三";collClass[1] = "李四";collClass[2] = "王五";for(int i=0;i<CollClass.max;i++){Console.WriteLine(collClass[i]);}}public class CollClass{public const int max = 3;private string[] arr;public CollClass(){arr = new string[max];}public string this[int index] //索引器{get { return arr[index]; }set { arr[index] = value; }}}
(4)委托和匿名方法

? ? ? ? 委托是一種引用類型,該引用類型與其他引用類型有所不同,在委托對象的引用中存放的不是對數據的引用,而是委托對方法的引用。(本質上是一種類型安全的函數指針)

? ? ? ? 語法:修飾符 delegate 返回類型 委托名稱 (參數列表)示例

  public class Test{public int Add(int x,int y){ return x + y; }}public delegate int add(int x,int y); //創建委托static void Main(string[] args){          Test test = new Test();add a = test.Add;  //創建委托對象int num = a(2, 3);Console.WriteLine(num);}

? ? ? ? 匿名方法允許一個與委托關聯的代碼內聯地寫入使用委托的位置,這使得代碼對于委托的實例很直接。

? ? ? ? 語法:delegate(參數列表) {? 代碼塊 } 。示例

  static void Main(string[] args){          //  Test test = new Test();//  add a = test.Add;add b = delegate(int x,int y) { return x + y; };int num = b.Invoke(2, 3);Console.WriteLine(num);}
(5)事件

? ? ? ? 1.委托的發布和訂閱(有點抽象)

? ? ? ? 通過委托實現事件處理的過程,通常有四個步驟:

? ? ? ? (1)定義委托類型,并在發布者類中定義一個該類型的公共成員。

? ? ? ? (2)在訂閱者類中定義委托處理方法。

? ? ? ? (3)訂閱者對象將事件處理方法鏈接到發布者對象的委托成員上。

? ? ? ? (4)發布者對象在特定情況下“激發”委托操作,從而自動調用訂閱者對象的委托處理方法。

示例:學校打鈴,學生執行對應的操作。(根據案例理解)

  public delegate void RingEvent(int ringKand);//參數代表鈴聲類型 1-上課 2-下課public class SchoolRing{public RingEvent OnBellSound; //委托public void Jow(int ringKand) //激發委托{if (ringKand == 1 || ringKand == 2){Console.WriteLine(ringKand == 1 ? "上課鈴響了" : "下課鈴響了");if (OnBellSound != null){OnBellSound(ringKand); }}else{Console.WriteLine("參數錯誤");}}}public class Student{public void SubRing(SchoolRing schoolRing) //訂閱委托{schoolRing.OnBellSound += SchoolJow;}public void SchoolJow(int ringKand) //委托處理方法{if (ringKand == 1){Console.WriteLine("上課了請學習");}else if (ringKand == 2){Console.WriteLine("下課了請休息");}}public void CancelSub(SchoolRing schoolRing)//取消委托{schoolRing.OnBellSound-=SchoolJow;}}static void Main(string[] args){          SchoolRing schoolRing = new SchoolRing(); //發布者Student student = new Student();//訂閱者student.SubRing(schoolRing); //訂閱委托Console.Write("請輸入參數(1-上課,2-下課):");schoolRing.Jow(Convert.ToInt32(Console.ReadLine())); //激發委托}

? ? ? ? 2.事件的發布和訂閱

? ? ? ? 事件處理機制,以保證事件訂閱的可靠性,其做法是在發布委托的定義中加上event關鍵字。其他不變。

   public event RingEvent OnBellSound; //委托

? ? ? ? 3.EventHandler類

? ? ? ? .NET專門定義了一個EventHandler委托類型,建議使用該類型作為事件的委托類型。

示例 將上邊的示例進行修改。

     public delegate void EventHandle(object sender,EventArgs e);//參數代表鈴聲類型 1-上課 2-下課public class SchoolRing{public event EventHandle OnBellSound; //委托public void Jow(int ringKand) //激發委托{if (ringKand == 1 || ringKand == 2){Console.WriteLine(ringKand == 1 ? "上課鈴響了" : "下課鈴響了");if(OnBellSound!=null){EventArgs e = new RingEventArgs(ringKand); //實例化參數類OnBellSound(this, e);}}else{Console.WriteLine("參數錯誤");}}}public class Student{public void SubRing(SchoolRing schoolRing) //訂閱委托{schoolRing.OnBellSound += SchoolJow;}public void SchoolJow(object sender,EventArgs e) //委托處理方法{if (((RingEventArgs)e).RingKand == 1){Console.WriteLine("上課了請學習");}else if (((RingEventArgs)e).RingKand == 2){Console.WriteLine("下課了請休息");}}public void CancelSub(SchoolRing schoolRing)//取消委托{schoolRing.OnBellSound-=SchoolJow;}}public class RingEventArgs : EventArgs //參數類{private int ringKand;public int RingKand{get { return ringKand; }}public RingEventArgs(int ringKand){this.ringKand = ringKand;}}

? ? ? ? 2.Window事件

? ? ? ? 事件在Windows這樣的圖形界面程序中很常用,事件響應時程序與用戶交互的基礎。

(6)迭代器

? ? ? ? 更相代替,反復更迭。重復執行統一過程。實現迭代器的接口IEnumerator接口。示例

 public class Family:System.Collections.IEnumerable //將類變為迭代類{string[] name = { "爸", "媽", "姐", "弟", "哥" };public IEnumerator GetEnumerator(){for (int i = 0; i < name.Length; i++){yield return name[i];}}}Family family = new Family();foreach(string str in family) //對類進行遍歷{richTextBox1.Text += str + "\n";}
(7)分部類

? ? ? ? 在類的前面加上partial關鍵字。

注意:分部類必須在同一程序集或同一模塊中進行定義。

? ? ? ? 分部類在界面開發的優點:每個控件都有生成代碼。VS將生成代碼放在分部類中。用戶就不需要管理這部分代碼。只需要專注于邏輯設計即可。

? ? ? ? 示例

    private void button1_Click(object sender, EventArgs e){Account account = new Account();int num1 = Convert.ToInt32(textBox1.Text);int num2 = Convert.ToInt32(textBox2.Text);switch (Convert.ToChar(comboBox1.Text)){case '+': textBox3.Text  = account.add(num1, num2).ToString(); break;case '-': textBox3.Text = account.sub(num1, num2).ToString(); break;case '*': textBox3.Text = account.mul(num1, num2).ToString(); break;case '/': textBox3.Text = account.div(num1, num2).ToString(); break;default:break;}}
}
partial class Account //分部類
{public int add(int x, int y){return x + y;}
}partial class Account
{public int sub(int x, int y){return x - y;}
}partial class Account
{public int mul(int x, int y){return x * y;}
}partial class Account
{public int div(int x, int y){return x / y;}
}
(8)泛型

? ? ? ? 1.類型參數T

? ? ? ? 可以看做是一個占位符,他不是一種類型,它僅代表某種可能的類型。在定義泛型時,T出現的位置可以使用任意一種類型代替。

? ? ? ? 2.泛型接口

? ? ? ? 與聲明一般接口的唯一區別是增加了一個<T>。一般來說,泛型接口與非泛型接口遵循相同的規則。

? ? ? ? 語法:interface 接口名<T>{ 接口體 }

? ? ? ? 示例

interface ITest<T>{T ShowInfo();}class Test<T, T1> : ITest<T1> where T : T1, new(){public T1 ShowInfo(){return new T();}}

? ? ? ? 3.泛型方法

? ? ? ? 泛型方法是在聲明中包括了參數類型T的方法。

? ? ? ? 語法:修飾符 void 方法名 <類型參數 T> {? 方法體 }

? ? ? ? 示例

  class sale{public static int sum<T>(T[] items){int sum = 0;foreach (T item in items){sum += Convert.ToInt32(item);}return sum;}}

第十三章 文件操作

(1)基本知識

? ? ? ? 1.System.IO命名空間

? ? ? ? 對文件進行操作時必須要引用的命名空間。

? ? ? ? 2.File類

? ? ? ? File類支持對文件的基本操作,包括創建、刪除、復制、移動和打開文件的靜態方法。由于方法都為靜態。使用File類的方法效率比使用對應的FileInfo實例方法可能要高。

? ? ? ? 3.FileInfo類

? ? ? ? FileInfo類與File類許多方法調用都是相同的,但FileInfo類沒有靜態方法,僅可以用于實例化對象。

(2)判斷文件是否存在

? ? ? ? File類和FileInfo類都包含判斷文件是否存在的方法。

? ? ? ? File類:public static bool Exists(string path);

? ? ? ? FileInfo類:public override bool Exists {get;}

示例

 bool isExits  = File.Exists("D:\\Desktop\\C#\\diedai\\123.txt");FileInfo fileInfo = new FileInfo("D:\\Desktop\\C#\\diedai\\123.txt");isExits = fileInfo.Exists;
(3)創建文件

?????????File類:public static FileStream Create(string path);

? ? ? ? FileInfo類:public Filestream Create();

示例

 File.Create("D:\\Desktop\\C#\\diedai\\test.txt");FileInfo fileInfo = new FileInfo("D:\\Desktop\\C#\\diedai\\test2.txt");fileInfo.Create();
(4)復制文件

? ? ? ? File類:public static void Copy(string sourceFileName,string destFileName);

? ? ? ? FileInfo類:public FileInfo CopyTo(string destFileName);

示例

           File.Copy("D:\\Desktop\\C#\\diedai\\123.txt", "D:\\Desktop\\C#\\diedai\\test.txt");string des = "D:\\Desktop\\C#\\diedai\\123.txt";FileInfo fileInfo = new FileInfo("D:\\Desktop\\C#\\diedai\\123.txt");fileInfo.CopyTo(des);
(5)移動文件

? ? ? ? File類:public static void Move(string sourceFileName,string destFileName);

? ? ? ? FileInfo類:public void MoveTo(string destFileName);

示例

  File.Move("D:\\Desktop\\C#\\diedai\\123.txt", "D:\\Desktop\\C#\\diedai\\test.txt");string des = "D:\\Desktop\\C#\\diedai\\123.txt";FileInfo fileInfo = new FileInfo("D:\\Desktop\\C#\\diedai\\123.txt");fileInfo.MoveTo(des);
(6)刪除文件

? ? ? ? File類:public static void Delete(string path);

? ? ? ? FileInfo類:public override void Delete();

示例

File.Delete("D:\\Desktop\\C#\\diedai\\123.txt");      
FileInfo fileInfo = new FileInfo("D:\\Desktop\\C#\\diedai\\123.txt");
fileInfo.Delete();
(7)獲取文件信息
 if (openFileDialog1.ShowDialog() == DialogResult.OK) {textBox1.Text = openFileDialog1.FileName;FileInfo fileInfo = new FileInfo(textBox1.Text);string Name = fileInfo.Name; //名稱string FullName = fileInfo.FullName; //路徑string CreateTime = fileInfo.CreationTime.ToLongDateString(); //創建時間long size = fileInfo.Length;//大小bool ReadOnly = fileInfo.IsReadOnly; //只讀屬性MessageBox.Show("名稱:" + Name +"\n路徑:" + FullName +"\n創建時間:" + CreateTime +"\n大小:" + size +"\n只讀屬性:" + ReadOnly);}

? ? ? ? 更多關于文件的屬性和方法可以參考開發文檔。

第十四章 文件夾操作

(1)Directory與DirectoryInfo類

? ? ? ? Directory類主要用于文件夾的基本操作,如移動、復制、重命名、創建和刪除等。也可獲取目錄的相關的屬性和信息。是靜態類,直接通過類名來調用。

? ? ? ? DirectoryInfo類與Directory類的關系類似于FileInfo類和File類。調用方法需要創建對象。

(2)判斷文件夾是否存在

????????Directory類:public static bool Exists(String path);

????????DirectoryInfo類:public override bool Exists{get;}??

示例

 Directory.Exists("D:\\Desktop\\C#\\diedai");DirectoryInfo info = new DirectoryInfo("D:\\Desktop\\C#\\diedai");if (info.Exists) { }
(3)創建文件夾? ??

????????Directory類:public static DirectoryInfo CreateDirectory(String path);

????????DirectoryInfo類:public void?Create()? ?

????????public void?Create(DirectorySecurity directorySecurity) //參數是應用此文件夾的訪問控制

示例

 Directory.CreateDirectory("D:\\Desktop\\C#\\test");DirectoryInfo info = new DirectoryInfo("D:\\Desktop\\C#\\test");info.Create();
(4)移動文件夾

????????Directory類:public static void Move(string sourceDirName,string destDirName);

? ? ? ? DirectoryInfo類:public void MoveTo(string destDirName);

示例

Directory.Move("D:\\Desktop\\C#\\test", "D:\\Desktop\\test");DirectoryInfo info = new DirectoryInfo("D:\\Desktop\\C#\\test");info.MoveTo("D:\\Desktop\\test");

注意,移動文件夾只能在相同根目錄下移動。例如,不能從C盤移動到D盤。

(5)刪除文件夾

?????????Directory類:public static void Delete(string path);

? ? ? ? DirectoryInfo類:public void Delete(bool recursive);//如果文件夾下有子文件夾,參數設置是否刪除子文件夾。?true刪除,false不刪除

????????public override void Delete();

示例

 Directory.Delete("D:\\Desktop\\C#\\test");DirectoryInfo info = new DirectoryInfo("D:\\Desktop\\C#\\test");info.Delete();//或info.Delete(true);
(6)遍歷文件夾

? ? ? ? 使用DirectoryInfo類。

? ? ? ? GetDirectories()——返回當前目錄的子目錄。

? ? ? ? GetFiles()——返回當前目錄的文件列表。

? ? ? ? GetFileSystemInfos()——返回包含目錄中子目錄和文件的FileSystemInfo對象的數組。

示例

  listView1.Items.Clear(); //清空列表if (folderBrowserDialog1.ShowDialog()==DialogResult.OK) //打開文件對話框{textBox1.Text = folderBrowserDialog1.SelectedPath; DirectoryInfo info = new DirectoryInfo(textBox1.Text); FileSystemInfo[] fileSystems = info.GetFileSystemInfos(); //獲取文件數組foreach (var item in fileSystems) //遍歷打印文件名和路徑{if (item is DirectoryInfo){DirectoryInfo info1 = new DirectoryInfo(item.FullName);listView1.Items.Add(info1.Name);listView1.Items[listView1.Items.Count-1].SubItems.Add(info1.FullName);}else{FileInfo fileInfo = new FileInfo(item.FullName);listView1.Items.Add(fileInfo.Name);listView1.Items[listView1.Items.Count - 1].SubItems.Add(fileInfo.FullName);}}}

第十五章 流操作類

? ? ? ?.NET FrameWork使用流來支持讀取和寫入文件,可以將流視為一組連續的一維數組。包括開頭和結尾,使用游標指示當前的位置。

(1)流操作

? ? ? ? 流中的數據可能來自內存、文件或套接字。流包含幾種基本操作:

? ? ? ? 1.讀取:將數據從流中傳輸到數據結構。

? ? ? ? 2.寫入:將數據從數據源傳輸到流中。

? ? ? ? 3.查詢:查詢和修改在流中的位置。

(2)流的類型

? ? ? ? ?.NET FrameWork流由Stream類表示,該類構成了其他所有流的抽象類。不能直接構建stream類的實例。但必須由它實現其中的一個類。

? ? ? ? C#中有許多類型的流,但在處理輸入和輸出時,最重要的流是FileStream類。它提供讀取和寫入文件的方式。

(3)文件流

? ? ? ? C#中,文件流使用FileStream類表示。一個FileStream類的實例代表了一個磁盤文件,它通過Seek方法進行對文件的隨機訪問,同時包含了流的標準輸入、輸出和錯誤等。默認文件打開方式是同步的,但也支持異步操作。

(4)對文件內容進行操作

? ? ? ? 示例:以四種不同方式對文件進行操作。

    FileMode filemode = FileMode.Open;//記錄打開的方式private void Form1_Load(object sender, EventArgs e){if (openFileDialog1.ShowDialog() == DialogResult.OK)textBox1.Text = openFileDialog1.FileName.ToString();}private void button1_Click_1(object sender, EventArgs e){string path = textBox1.Text;try{using (FileStream fs = File.Open(path, filemode)) //讀文件內容{Byte[] info = new UTF8Encoding(true).GetBytes(textBox2.Text);fs.Write(info, 0, info.Length);}using (FileStream fs = File.Open(path, FileMode.Open)) //寫文件內容{byte[] bytes = new byte[1024];UTF8Encoding temp = new UTF8Encoding(true);string pp = "";while (fs.Read(bytes, 0, bytes.Length) > 0){pp += temp.GetString(bytes);}MessageBox.Show(pp);}}catch{if (MessageBox.Show("文件不存在,是否創建文件", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes){FileStream fs = File.Open(path, FileMode.CreateNew);fs.Dispose();}}}private void radioButton1_CheckedChanged(object sender, EventArgs e) //讀寫方式打開{if (((RadioButton)sender).Checked == true){filemode = FileMode.Open;}}private void radioButton2_CheckedChanged(object sender, EventArgs e) //追加方式打開{if (((RadioButton)sender).Checked == true)filemode = FileMode.Append;}private void radioButton3_CheckedChanged(object sender, EventArgs e) //清空后打開{if(((RadioButton)sender).Checked == true)filemode = FileMode.Truncate;}private void radioButton4_CheckedChanged(object sender, EventArgs e) //覆蓋方式打開{if (((RadioButton)sender).Checked == true)filemode = FileMode.Create;}
}
(5)文本文件的讀寫

? ? ? ? 文本文件的寫入和讀取主要是通過StreamWriter類和StreamReader類來實現的。

? ? ? ? 示例 :寫文件

 if (!File.Exists("D:\\Desktop\\C#\\Log2.txt")){File.Create("D:\\Desktop\\C#\\Log2.txt");} string strLog = textBox1.Text + "  "+ DateTime.Now;if (textBox1.Text != " " && textBox2.Text != " "){using (StreamWriter writer = new StreamWriter("D:\\Desktop\\C#\\Log2.txt", append: true)){writer.WriteLine(strLog);}Form2 form2 = new Form2();form2.Show();}

? ? ? ? 讀文件

 using (StreamReader reader = new StreamReader("D:\\Desktop\\C#\\Log2.txt", Encoding.UTF8)){string line = string.Empty;string[] split = new string[] { "  " };while ((line = reader.ReadLine())!= null){string[] strLogs = line.Split(split, StringSplitOptions.RemoveEmptyEntries);ListViewItem list = new ListViewItem();list.SubItems.Clear();list.SubItems[0].Text = strLogs[0];list.SubItems.Add(strLogs[1]);listView1.Items.Add(list);}}    

? ? ? ? 本文內容到此為止,謝謝觀看。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/bicheng/75287.shtml
繁體地址,請注明出處:http://hk.pswp.cn/bicheng/75287.shtml
英文地址,請注明出處:http://en.pswp.cn/bicheng/75287.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

【區塊鏈安全 | 第十四篇】類型之值類型(一)

文章目錄 值類型布爾值整數運算符取模運算指數運算 定點數地址&#xff08;Address&#xff09;類型轉換地址成員balance 和 transfersendcall&#xff0c;delegatecall 和 staticcallcode 和 codehash 合約類型&#xff08;Contract Types&#xff09;固定大小字節數組&#x…

Windows 系統下多功能免費 PDF 編輯工具詳解

IceCream PDF Editor是一款極為實用且操作簡便的PDF文件編輯工具&#xff0c;它完美適配Windows操作系統。其用戶界面設計得十分直觀&#xff0c;哪怕是初次接觸的用戶也能快速上手。更為重要的是&#xff0c;該軟件具備豐富多樣的強大功能&#xff0c;能全方位滿足各類PDF編輯…

vue3相比于vue2的提升

性能提升&#xff1a; Vue3的頁面渲染速度更快、性能更好。特別是在處理大量數據和復雜組件時&#xff0c;優勢更加明顯。Vue3引入了編譯時優化&#xff0c;如靜態節點提升&#xff08;hoistStatic&#xff09;、補丁標志&#xff08;patchflag&#xff09;等&#xff0c;這些…

Redis 梳理匯總目錄

Redis 哨兵集群&#xff08;Sentinel&#xff09;與 Cluster 集群對比-CSDN博客 如何快速將大規模數據保存到Redis集群-CSDN博客 Redis的一些高級指令-CSDN博客 Redis 篇-CSDN博客

【奇點時刻】GPT-4o新生圖特性深度洞察報告

以下報告圍繞最新推出的「GPT4o」最新圖像生成技術展開&#xff0c;旨在讓讀者從整體層面快速了解其技術原理、功能亮點&#xff0c;以及與其他常見圖像生成或AI工具的對比分析&#xff0c;同時也會客觀探討該技術在應用過程中可能遇到的挑戰與限制。 1. 技術背景概述 GPT4o新…

【算法day28】解數獨——編寫一個程序,通過填充空格來解決數獨問題

37. 解數獨 編寫一個程序&#xff0c;通過填充空格來解決數獨問題。 數獨的解法需 遵循如下規則&#xff1a; 數字 1-9 在每一行只能出現一次。 數字 1-9 在每一列只能出現一次。 數字 1-9 在每一個以粗實線分隔的 3x3 宮內只能出現一次。&#xff08;請參考示例圖&#xff…

【已解決】Javascript setMonth跨月問題;2025-03-31 setMonth后變成 2025-05-01

文章目錄 bug重現解決方法&#xff1a;用第三方插件來實現&#xff08;不推薦原生代碼來實現&#xff09;。項目中用的有dayjs。若要自己實現&#xff0c;參考 AI給出方案&#xff1a; bug重現 今天&#xff08;2025-04-01&#xff09;遇到的一個問題。原代碼邏輯大概是這樣的…

力扣刷題-熱題100題-第29題(c++、python)

19. 刪除鏈表的倒數第 N 個結點 - 力扣&#xff08;LeetCode&#xff09;https://leetcode.cn/problems/remove-nth-node-from-end-of-list/description/?envTypestudy-plan-v2&envIdtop-100-liked 計算鏈表長度 對于鏈表&#xff0c;難的就是不知道有多少元素&#xff…

【QT】QT的多界面跳轉以及界面之間傳遞參數

QT的多界面跳轉以及界面之間傳遞參數 一、在QT工程中添加新的界面二、多界面跳轉的兩種情況1、A界面跳到B界面&#xff0c;不需要返回2、A界面跳到B界面&#xff0c;需要返回1&#xff09;使用this指針傳遞將當前界面地址傳遞給下一界面2&#xff09;使用parentWidget函數獲取上…

【力扣hot100題】(022)反轉鏈表

非常經典&#xff0c;我寫的比較復雜&#xff0c;一直以來的思路都是這樣&#xff0c;就沒有去找更簡單的解法&#xff1a;&#xff08;做鏈表題習慣加頭結點的前置節點了&#xff0c;去掉也行&#xff09; /*** Definition for singly-linked list.* struct ListNode {* …

劍指Offer(數據結構與算法面試題精講)C++版——day2

劍指Offer(數據結構與算法面試題精講)C++版——day2 題目一:只出現一次的數據題目二:單詞長度的最大乘積題目三:排序數組中的兩個數字之和題目一:只出現一次的數據 一種很簡單的思路是,使用數組存儲出現過的元素,比如如果0出現過,那么arr[0]=1,但是有個問題,題目中沒…

【C++游戲引擎開發】《線性代數》(3):矩陣乘法的SIMD優化與轉置加速

一、矩陣乘法數學原理與性能瓶頸 1.1 數學原理 矩陣乘法定義為:給定兩個矩陣 A ( m n ) \mathrm{A}(mn) A(mn)和 B ( n p ) \mathrm{B}(np) B(np),它們的乘積 C = A B \mathrm{C}=AB C=AB 是一個 m p \mathrm{m}p mp 的矩陣,其中: C i , j = ∑ k = 1…

Vue Transition組件類名+TailwindCSS

#本文教學結合TailwindCSS實現一個Transition動畫的例子# 舉例代碼&#xff1a; <transition enter-active-class"transition-all duration-300 ease-out"enter-from-class"opacity-0 translate-y-[-10px]"enter-to-class"opacity-100 translate-…

技術回顧day2

1.獲取文件列表 流程&#xff1a;前端根據查詢條件封裝查詢信息&#xff0c;后端接收后進行封裝&#xff0c;封裝為FileInfoQuery,根據fileInfoQuery使用mybatis的動態sql來進行查詢。 2.文件分片上傳 每次上傳需要上傳包括(文件名字&#xff0c;文件&#xff0c;md5值&#…

DeepSeek-R1 模型現已在亞馬遜云科技上提供

2025年3月10日更新—DeepSeek-R1現已作為完全托管的無服務器模型在Amazon Bedrock上提供。 2025年2月5日更新—DeepSeek-R1 Distill Llama 和 Qwen模型現已在Amazon Bedrock Marketplace和Amazon SageMaker JumpStart中提供。 在最近的Amazon re:Invent大會上&#xff0c;亞馬…

STP --- 生成樹協議

協議信息 配置 BPDU Protocol identifier&#xff1a;協議標識 Version&#xff1a;協議版本&#xff1a;STP 為 0&#xff0c;RSTP 為 2&#xff0c;MSTP 為 3 type&#xff1a; BPDU 類型 Flag&#xff1a; 標志位 Root ID&#xff1a; 根橋 ID&#xff0c;由兩字節的優…

Ansible playbook-ansible劇本

一.playbook介紹 便于功能的重復使用 本質上就是文本文件&#xff0c;一般都是以.yml結尾的文本文件。 1.遵循YAML語法 1.要求同級別代碼要有相同縮進&#xff0c;建議4個空格。【同級別代碼是同一邏輯的代碼】 在計算機看來空格和Tob鍵是兩個不同的字符。 2.一個鍵對應一…

python的基礎入門

初識Python 什么是Python Python是1門程序設計語言。在開發者眼里&#xff0c;語言可以分為3類&#xff1a; 自然語言&#xff1a;人能聽懂的語言&#xff0c;例如漢語&#xff0c;英語&#xff0c;法語等等。機器語言&#xff1a;機器能聽懂的語言&#xff0c;機器只能聽懂0…

MD編輯器中的段落縮進怎么操作

在 Markdown&#xff08;MD&#xff09;編輯器中&#xff0c;段落的縮進通常可以通過 HTML 空格符、Markdown 列表縮進、代碼塊縮進等方式 實現。以下是幾種常見的段落縮進方法&#xff1a; 1. 使用全角空格 ( ) 在一些 Markdown 編輯器&#xff08;如 Typora&#xff09;中&…

8.neo4j圖數據庫python操作

使用圖數據庫的原因 圖數據庫使用neo4j的原因&#xff1a;neo4j使用率高&#xff0c;模板好找&#xff0c;報錯能查。 紅樓夢人物關系圖地址 GraphNavigator neo4j學習手冊 https://www.w3cschool.cn/neo4j/neo4j_need_for_graph_databses.html CQL代表的是Cypher查詢語言…