亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

C# リンクリスト

Sep 03, 2024 pm 03:28 PM
c# c# tutorial

要素を不連続に格納するための線形データ構(gòu)造は LinkedList と呼ばれます。この構(gòu)造では、リンク リスト內(nèi)の要素を相互にリンクするためにポインターが使用され、System.Collections.Generic 名前空間は LinkedList< で構(gòu)成されます。 T> C# のクラス。古典的なリンク リストを?qū)g裝する非常に迅速な方法で要素を削除または挿入でき、各オブジェクトの割り當(dāng)てはリンク リスト內(nèi)で分離されており、特定の操作を?qū)g行するためにコレクション全體をコピーする必要はありません。リンクリストにあります。

構(gòu)文:

C# の LinkedList クラスの構(gòu)文は次のとおりです。

LinkedList<Type> linkedlist_name = new LinkedList <Type>();
</p>
<p>Type はリンク リストのタイプを表します。</p>
<h3>C# での LinkedList クラスの動作</h3>
<ul>
<li>リンク リストにはノードが存在し、すべてのノードは 2 つの部分、つまりデータ フィールドとリンク リストの次に來るノードへのリンクで構(gòu)成されます。</li>
<li>リンクされたリスト內(nèi)のすべてのノードのタイプは LinkedListNode<T> です。 </li> と入力します。
<li>ノードはリンク リストから削除でき、同じリンク リストに挿入し直すことも、別のリンク リストに挿入することもできるため、ヒープに追加の割り當(dāng)てはありません。</li>
<li>リンク リストへの要素の挿入、リンク リストからの要素の削除、および Liked リストによって維持される內(nèi)部プロパティである count のプロパティの取得は、すべて O(1) 操作です。</li>
<li>列挙子は汎用リンク リストであるため、リンク リスト クラスによってサポートされます。</li>
<li>リンク リストに矛盾をもたらすものは、リンク リストではサポートされていません。</li>
<li>リンク リストが二重リンク リストの場合、各ノードには 2 つのポインターがあり、1 つはリスト內(nèi)の前のノードを指し、もう 1 つはリスト內(nèi)の次のノードを指します。</li>
</ul>
<h3>LinkedList クラスのコンストラクター</h3>
<p>C# の LinkedList クラスにはいくつかのコンストラクターがあります。それらは次のとおりです:</p>


<ul>
<li>
<strong>LinkedList(): </strong>空のリンク リスト クラスの新しいインスタンスが初期化されます。</li>
<li>
<strong>LinkedList(IEnumerable): </strong>コピーされたすべての要素を蓄積するのに十分な容量を持つ IEnumerable の指定された実裝から取得されたリンク リスト クラスの新しいインスタンスが初期化されます。</li>
<li>
<strong>LinkedList(SerializationInfo, StreamingContext): </strong>リンク リスト クラスの新しいインスタンスが初期化され、パラメータとして指定された SerializationInfo と StreamingContext を使用してシリアル化できます。</li>
</ul>
<h3>C# の LinkedList クラスのメソッド</h3>
<p>C# の LinkedList クラスにはいくつかのメソッドがあります。それらは次のとおりです:</p>
<ul>
<li>
<strong>AddAfter: </strong>A value or new node is added after an already present node in the linked list using the AddAfter method.</li>
<li>
<strong>AddFirst: </strong>A value or new node is added at the beginning of the linked list using the AddFirst method.</li>
<li>
<strong>AddBefore: </strong>A value or new node is added before an already present node in the linked list using the AddBefore method.</li>
<li>
<strong>AddLast: </strong>A value or new node is added at the end of the linked list using the AddLast method.</li>
<li>
<strong>Remove(LinkedListNode): </strong>A node specified as a parameter will be removed from the linked list using Remove(LinkedListNode) method.</li>
<li>
<strong>RemoveFirst(): </strong>A node at the beginning of the linked list will be removed from the linked list using RemoveFirst() method.</li>
<li>
<strong>Remove(T): </strong>The first occurrence of the value specified as a parameter in the linked list will be removed from the linked list using the Remove(T) method.</li>
<li>
<strong>RemoveLast(): </strong>A node at the end of the linked list will be removed from the linked list using the RemoveLast() method.</li>
<li>
<strong>Clear(): </strong>All the nodes from the linked list will be removed using the Clear() method.</li>
<li>
<strong>Find(T): </strong>The value specified as the parameter present in the very first node will be identified by using the Find(T) method.</li>
<li>
<strong>Contains(T): </strong>We can use the Contains(T) method to find out if a value is present in the linked list or not.</li>
<li>
<strong>ToString(): </strong>A string representing the current object is returned by using the ToString() method.</li>
<li>
<strong>CopyTo(T[], Int32): </strong>The whole linked list is copied to an array which is one dimensional and is compatible with the linked list and the linked list begins at the index specified in the array to be copied to using CopyTo(T[], Int32) method.</li>
<li>
<strong>OnDeserialization(Object): </strong>After the completion of deserialization, an event of deserialization is raised and the ISerializable interface is implemented using OnDeserialization(Object) method.</li>
<li>
<strong>Equals(Object): </strong>If the object specified as the parameter is equal to the current object or not is identified using Equals(Object) method.</li>
<li>
<strong>FindLast(T): </strong>The value specified as the parameter present in the last node will be identified by using FindLast(T) method.</li>
<li>
<strong>MemberwiseClone(): </strong>A shallow copy of the current object is created using MemeberwiseClone() method.</li>
<li>
<strong>GetEnumerator(): </strong>An enumerator is returned using GetEnumerator() method and the returned enumerator loops through the linked list.</li>
<li>
<strong>GetType(): </strong>The type of the current instance is returned using GetType() method.</li>
<li>
<strong>GetHashCode(): </strong>The GetHashCode() method is the hash function by default.</li>
<li>
<strong>GetObjectData(SerializationInfo, StreamingContext): </strong>The data which is necessary to make the linked list serializable is returned by using GetObjectData(SerializationInfo, StreamingContext) method along with implementing the ISerializable interface.</li>
</ul>
<h3>Example of LinkedList Class in C#</h3>
<p>C# program to demonstrate AddLast() method, Remove(LinkedListNode) method, Remove(T) method, RemoveFirst() method, RemoveLast() method and Clear() method in Linked List class:</p>
<p><strong>Code:</strong></p>


<pre class="brush:php;toolbar:false">using System;
using System.Collections.Generic;
//a class called program is defined
public class program
{
// Main Method is called
static public void Main()
{
//a new linked list is created
LinkedList<String> list = new LinkedList<String>();
//AddLast() method is used to add the elements to the newly created linked list
list.AddLast("Karnataka");
list.AddLast("Mumbai");
list.AddLast("Pune");
list.AddLast("Hyderabad");
list.AddLast("Chennai");
list.AddLast("Delhi");
Console.WriteLine("The states in India are:");
//Using foreach loop to display the elements of the newly created linked list
foreach(string places in list)
{
Console.WriteLine(places);
}
Console.WriteLine("The places after using Remove(LinkedListNode) method are:");
//using Remove(LinkedListNode) method to remove a node from the linked list
list.Remove(list.First);
foreach(string place in list)
{
Console.WriteLine(place);
}
Console.WriteLine("The places after using Remove(T) method are:");
//using Remove(T) method to remove a node from the linked list
list.Remove("Chennai");
foreach(string plac in list)
{
Console.WriteLine(plac);
}
Console.WriteLine("The places after using RemoveFirst() method are:");
//using RemoveFirst() method to remove the first node from the linked list
list.RemoveFirst();
foreach(string pla in list)
{
Console.WriteLine(pla);
}
Console.WriteLine("The places after using RemoveLast() method are:");
//using RemoveLast() method to remove the last node from the linked list
list.RemoveLast();
foreach(string pl in list)
{
Console.WriteLine(pl);
}
//using Clear() method to remove all the nodes from the linked list
list.Clear();
Console.WriteLine("The count of places after using Clear() method is: {0}",
list.Count);
}
}

The output of the above program is as shown in the snapshot below:

C# リンクリスト

In the above program, a class called program is defined. Then the main method is called. Then a new linked list is created. Then AddLast() method is used to add the elements to the newly created linked list. Then foreach loop is used to display the elements of the newly created linked list. Then Remove(LinkedListNode) method is used to remove a node from the linked list. Then Remove(T) method is used to remove a node from the linked list. Then RemoveFirst() method is used to remove the first node from the linked list. Then RemoveLast() method is used to remove the last node from the linked list. Then Clear() method is used to remove all the nodes from the linked list. The output of the program is shown in the snapshot above.

以上がC# リンクリストの詳細內(nèi)容です。詳細については、PHP 中國語 Web サイトの他の関連記事を參照してください。

このウェブサイトの聲明
この記事の內(nèi)容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰屬します。このサイトは、それに相當(dāng)する法的責(zé)任を負(fù)いません。盜作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡(luò)ください。

ホットAIツール

Undress AI Tool

Undress AI Tool

脫衣畫像を無料で

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード寫真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

寫真から衣服を削除するオンライン AI ツール。

Clothoff.io

Clothoff.io

AI衣類リムーバー

Video Face Swap

Video Face Swap

完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

ホットツール

メモ帳++7.3.1

メモ帳++7.3.1

使いやすく無料のコードエディター

SublimeText3 中國語版

SublimeText3 中國語版

中國語版、とても使いやすい

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統(tǒng)合開発環(huán)境

ドリームウィーバー CS6

ドリームウィーバー CS6

ビジュアル Web 開発ツール

SublimeText3 Mac版

SublimeText3 Mac版

神レベルのコード編集ソフト(SublimeText3)

マルチスレッドと非同期C#の違い マルチスレッドと非同期C#の違い Apr 03, 2025 pm 02:57 PM

マルチスレッドと非同期の違いは、マルチスレッドが複數(shù)のスレッドを同時に実行し、現(xiàn)在のスレッドをブロックせずに非同期に操作を?qū)g行することです。マルチスレッドは計算集約型タスクに使用されますが、非同期はユーザーインタラクションに使用されます。マルチスレッドの利點は、コンピューティングのパフォーマンスを改善することですが、非同期の利點はUIスレッドをブロックしないことです。マルチスレッドまたは非同期を選択することは、タスクの性質(zhì)に依存します。計算集約型タスクマルチスレッド、外部リソースと相互作用し、UIの応答性を非同期に使用する必要があるタスクを使用します。

C#対C:歴史、進化、將來の見通し C#対C:歴史、進化、將來の見通し Apr 19, 2025 am 12:07 AM

C#とCの歴史と進化はユニークであり、將來の見通しも異なります。 1.Cは、1983年にBjarnestrostrupによって発明され、オブジェクト指向のプログラミングをC言語に導(dǎo)入しました。その進化プロセスには、C 11の自動キーワードとラムダ式の導(dǎo)入など、複數(shù)の標(biāo)準(zhǔn)化が含まれます。C20概念とコルーチンの導(dǎo)入、將來のパフォーマンスとシステムレベルのプログラミングに焦點を當(dāng)てます。 2.C#は2000年にMicrosoftによってリリースされました。CとJavaの利點を組み合わせて、その進化はシンプルさと生産性に焦點を當(dāng)てています。たとえば、C#2.0はジェネリックを?qū)毪?、C#5.0は非同期プログラミングを?qū)毪筏蓼筏?。これは、將來の開発者の生産性とクラウドコンピューティングに焦點を當(dāng)てます。

XMLの形式を変更する方法 XMLの形式を変更する方法 Apr 03, 2025 am 08:42 AM

XML形式を変更する方法はいくつかあります。Atepadなどのテキストエディターを使用して手動で編集する。 XmlBeautifierなどのオンラインまたはデスクトップXMLフォーマットツールを使用して自動的にフォーマットします。 XSLTなどのXML変換ツールを使用して変換ルールを定義します。または、Pythonなどのプログラミング言語を使用して解析および操作します。元のファイルを変更してバックアップするときは注意してください。

XMLを単語に変換する方法 XMLを単語に変換する方法 Apr 03, 2025 am 08:15 AM

XMLを単語に変換するには、Microsoft Wordの使用、XMLコンバーターの使用、またはプログラミング言語の使用方法が3つあります。

XMLをJSONに変換する方法 XMLをJSONに変換する方法 Apr 03, 2025 am 09:09 AM

XMLをJSONに変換する方法は次のとおりです。プログラミング言語(Python、Java、C#など)でスクリプトまたはプログラムを作成して変換します。オンラインツール(XMLからJSON、GojkoのXMLコンバーター、XMLオンラインツールなど)を使用してXMLデータを貼り付けまたはアップロードし、JSON形式の出力を選択します。 XMLからJSONコンバーターを使用して変換タスクを?qū)g行します(酸素XMLエディター、Stylus Studio、Altova XMLSpyなど)。 XSLT StyleSheetsを使用してXMLをJSONに変換します。データ統(tǒng)合ツールを使用しています(Informaticなど

C#マルチスレッドプログラミングとは何ですか? C#マルチスレッドプログラミングでは、C#マルチスレッドプログラミングを使用します C#マルチスレッドプログラミングとは何ですか? C#マルチスレッドプログラミングでは、C#マルチスレッドプログラミングを使用します Apr 03, 2025 pm 02:45 PM

C#マルチスレッドプログラミングは、プログラムが複數(shù)のタスクを同時に実行できるようにするテクノロジーです。パフォーマンスを改善し、応答性を改善し、並列処理を?qū)g裝することにより、プログラムの効率を改善できます。スレッドクラスはスレッドを直接作成する方法を提供しますが、タスクやAsync/待望などの高度なツールは、より安全な非同期操作とクリーンなコード構(gòu)造を提供できます。マルチスレッドプログラミングの一般的な課題には、デッドロック、レース條件、リソースリークが含まれます。これらのリソースモデルの設(shè)計と、これらの問題を回避するために適切な同期メカニズムの使用が必要です。

C#.NET:.NETエコシステムを使用したアプリケーションの構(gòu)築 C#.NET:.NETエコシステムを使用したアプリケーションの構(gòu)築 Apr 27, 2025 am 12:12 AM

.NETを使用してアプリケーションを構(gòu)築する方法は? .NETを使用してアプリケーションを構(gòu)築することは、次の手順を通じて達成できます。1)C#言語やクロスプラットフォーム開発サポートを含む.NETの基本を理解します。 2)コンポーネントや.NETエコシステムの作業(yè)原則などのコア概念を?qū)W習(xí)します。 3)単純なコンソールアプリケーションから複雑なWebAPISおよびデータベース操作まで、基本的および高度な使用をマスターします。 4)構(gòu)成やデータベース接続の問題など、一般的なエラーとデバッグ手法に精通している。 5)アプリケーションのパフォーマンスの最適化と非同期プログラミングやキャッシュなどのベストプラクティス。

Webからデスクトップまで:C#.NETの汎用性 Webからデスクトップまで:C#.NETの汎用性 Apr 15, 2025 am 12:07 AM

c#.netisversatileforbothwebanddesktopdevelopment.1)forweb、useasp.netfordynamicapplications.2)fordesktop、equindowsorwpfforrichinterfaces.3)usexamarinforcross-platformdeveliment、enabling deshacrosswindows、

See all articles