কম্পিউটার

C# কপি() পদ্ধতি


C#-এ কপি() পদ্ধতিটি একটি নির্দিষ্ট স্ট্রিং-এর মতো একই মান সহ স্ট্রিংয়ের একটি নতুন উদাহরণ তৈরি করতে ব্যবহৃত হয়।

সিনট্যাক্স

public static string Copy (string s);

উপরে, s হল কপি করার স্ট্রিং।

উদাহরণ

using System;
public class Demo {
   public static void Main(string[] args) {
      string s1 = "Amy";
      string s2 = "Katie";
      string s3 = String.Copy(s2);
      Console.WriteLine("String1 = "+s1);
      Console.WriteLine("String2 = "+s2);
      Console.WriteLine("Are both the strings equal? = "+s1.Equals(s2));
      Console.WriteLine("Are both the strings equal? = "+s2.Equals(s3));
      Console.WriteLine(string.CompareOrdinal(s1, s2));
      Console.WriteLine(string.CompareOrdinal(s2, s3));
   }
}

আউটপুট

String1 = Amy
String2 = Katie
Are both the strings equal? = False
Are both the strings equal? = True
-10
0

উদাহরণ

using System;
public class Demo {
   public static void Main(string[] args) {
      string s1 = "Gary";
      string s2 = "Gary";
      string s3 = String.Copy(s2);
      Console.WriteLine("String1 = "+s1);
      Console.WriteLine("String2 = "+s2);
      Console.WriteLine("Is s1 and s2 equal? = "+s1.Equals(s2));
      Console.WriteLine("Is s2 and s3 equal? = "+s2.Equals(s3));
      s3 = "Harry";
      Console.WriteLine("Is s2 and s3 equal? = "+s2.Equals(s3));
   }
}

আউটপুট

String1 = Gary
String2 = Gary
Is s1 and s2 equal? = True
Is s2 and s3 equal? = True
Is s2 and s3 equal? = False

  1. C# এ DateTime.ToLongTimeString() পদ্ধতি

  2. C# String.PadRight পদ্ধতি

  3. C# SingleorDefault() পদ্ধতি

  4. স্ট্রিং Join() পদ্ধতি