SlideShare a Scribd company logo
Renas R. Rekany Object-Oriented-Programming L3B
1
String Functions Definitions
Clone() Make clone of string.
CompareTo()
Compare two strings and returns integer value as output.
It returns 0 for true and 1 for false.
Contains()
The C# Contains method checks whether specified
character or string is exists or not in the string value.
EndsWith()
This EndsWith Method checks whether specified
character is the last character of string or not.
Equals()
The Equals Method in C# compares two string and
returns Boolean value as output.
GetHashCode() This method returns HashValue of specified string.
GetType() It returns the System.Type of current instance.
GetTypeCode() It returns the Stystem.TypeCode for class System.String.
IndexOf()
Returns the index position of first occurrence of specified
character.
ToLower()
Converts String into lower case based on rules of the
current culture.
ToUpper()
Converts String into Upper case based on rules of the
current culture.
Insert()
Insert the string or character in the string at the specified
position.
IsNormalized()
This method checks whether this string is in Unicode
normalization form C.
LastIndexOf()
Returns the index position of last occurrence of specified
character.
Length It is a string property that returns length of string.
Remove()
This method deletes all the characters from beginning to
specified index position.
Replace() This method replaces the character.
Split() This method splits the string based on specified value.
StartsWith()
It checks whether the first character of string is same as
specified character.
Substring() This method returns substring.
ToCharArray() Converts string into char array.
Trim()
It removes extra whitespaces from beginning and ending
of string.
Renas R. Rekany Object-Oriented-Programming L3B
2
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string s,fn, ln;
fn = textBox1.Text;
ln = textBox2.Text;
s = comboBox1.Text;
switch (s)
{
case "Clone":
textBox3.Text=Convert.ToString( fn.Clone());
textBox4.Text=Convert.ToString(ln.Clone());
break;
case "CompareTo":
int b = fn.CompareTo(ln);
if (b == 0)
MessageBox.Show("False");
else if (b == 1)
MessageBox.Show("True");
break;
case "Contains":
MessageBox.Show(Convert.ToString( fn.Contains("W")));
break;
case "EndsWith":
MessageBox.Show(Convert.ToString( fn.EndsWith("d")));
break;
case "Equals":
MessageBox.Show(Convert.ToString( fn.Equals(ln)));
break;
case "GetHashCode":
textBox3.Text =Convert.ToString( fn.GetHashCode());
textBox4.Text =Convert.ToString( ln.GetHashCode());
break;
case "GetType":
Renas R. Rekany Object-Oriented-Programming L3B
3
textBox3.Text = Convert.ToString(fn.GetType ());
textBox4.Text = Convert.ToString(ln.GetType ());
break;
case "GetTypeCode":
textBox3.Text = Convert.ToString(fn.GetTypeCode ());
textBox4.Text = Convert.ToString(ln.GetTypeCode ());
break;
case "IndexOf":
textBox3.Text = Convert.ToString(fn.IndexOf("e"));
textBox4.Text = Convert.ToString(ln.IndexOf("o"));
break;
case "ToLower":
textBox3.Text = Convert.ToString(fn.ToLower());
textBox4.Text = Convert.ToString(ln.ToLower());
break;
case "ToUpper":
textBox3.Text = Convert.ToString(fn.ToUpper());
textBox4.Text = Convert.ToString(ln.ToUpper());
break;
case "Insert":
textBox3.Text = Convert.ToString(fn.Insert(0, "Hi "));
textBox4.Text = Convert.ToString(ln.Insert(0, " Hi "));
break;
case "IsNormalized":
MessageBox.Show(Convert.ToString(fn.IsNormalized()));
break;
case "LastIndexOf":
textBox3.Text = Convert.ToString(fn.LastIndexOf("o"));
textBox4.Text = Convert.ToString(ln.LastIndexOf("s"));
break;
case "Length":
textBox3.Text = Convert.ToString(fn.Length);
textBox4.Text = Convert.ToString(ln.Length);
break;
case "Remove":
textBox3.Text = Convert.ToString(fn.Remove(5));
textBox4.Text = Convert.ToString(ln.Remove(0,4));
break;
case "Replace":
textBox3.Text = Convert.ToString(fn.Replace("o", "*"));
textBox4.Text = Convert.ToString(ln.Replace("w", "*"));
break;
case "Split":
string[] split1 = fn.Split(new char[] { 'o' });
textBox3.Text = split1[0];
string[] split2 = ln.Split(new char[] { 'd' });
textBox4.Text = split2[1];
break;
case "StartsWith":
textBox3.Text=Convert.ToString(fn.StartsWith("O"));
Renas R. Rekany Object-Oriented-Programming L3B
4
textBox4.Text = Convert.ToString(ln.StartsWith("W"));
break;
case "SubString":
textBox3.Text = Convert.ToString(fn.Substring(2, 5));
textBox4.Text = Convert.ToString(ln.Substring(4, 5));
break;
case "ToCharArray":
char[] s1 = fn.ToCharArray();
char [] s2= ln.ToCharArray();
for (int i = 0; i < fn.Length; i++)
{
textBox3.Text = textBox3.Text + s1[i];
}
for (int i = 0; i < ln.Length ; i++)
{
textBox4.Text = textBox4.Text + s2[i];
}
break;
case "Trim":
textBox3.Text = Convert.ToString(fn.Trim());
textBox4.Text = Convert.ToString(ln.Trim(new char[] {'s'}));
break;
}
}
}
}

More Related Content

PDF
Write a program that initializes an array - of - double and then copies the c...
PPT
Phyton Learning extracts
PPTX
Python for loop
PPTX
Quiz On Strings
PPTX
Classes function overloading
PPT
Link list part 1
PPTX
Regular expressions in Python
PPT
Introduction to Python - Part Three
Write a program that initializes an array - of - double and then copies the c...
Phyton Learning extracts
Python for loop
Quiz On Strings
Classes function overloading
Link list part 1
Regular expressions in Python
Introduction to Python - Part Three

What's hot (20)

PPTX
Pointer basics
PPTX
R programming Language
PPTX
Loops in Python
PDF
Python-02| Input, Output & Import
PPTX
Introduction To Programming with Python-3
PDF
Iteration, induction, and recursion
PPTX
Python Homework Help
PPTX
Jsp session 12
PDF
Introduction to Python
PPTX
Python advance
PDF
DEFUN 2008 - Real World Haskell
PPT
Introduction to Python - Part Two
PPTX
Python language data types
PPT
Data Structures- Part5 recursion
PDF
C faqs interview questions placement paper 2013
PPTX
Software Craftsmanship - 2
ODP
2.2 higher order-functions
PPSX
Programming with Python
PPTX
Ruby basics || updated
Pointer basics
R programming Language
Loops in Python
Python-02| Input, Output & Import
Introduction To Programming with Python-3
Iteration, induction, and recursion
Python Homework Help
Jsp session 12
Introduction to Python
Python advance
DEFUN 2008 - Real World Haskell
Introduction to Python - Part Two
Python language data types
Data Structures- Part5 recursion
C faqs interview questions placement paper 2013
Software Craftsmanship - 2
2.2 higher order-functions
Programming with Python
Ruby basics || updated
Ad

Similar to C# p6 (20)

PPTX
Tokens in php (php: Hypertext Preprocessor).pptx
PDF
PPTX
String, string builder, string buffer
TXT
New text document
PPTX
stringstringbuilderstringbuffer-190830060142.pptx
PPTX
Header file.pptx
PDF
Javascript objects, properties and methods .pdf
PDF
C interview-questions-techpreparation
PDF
C Interview Questions for Fresher
PDF
C interview Question and Answer
PDF
C interview-questions-techpreparation
PPT
JavaScript Objects
PDF
Module 6 - String Manipulation.pdf
PPTX
13string in c#
PPS
String and string buffer
PPT
Chapter3 basic java data types and declarations
PPT
PPT
Pertemuan 6-2-sequence-diagram
PPT
Control structures i
PPTX
Java String Handling
Tokens in php (php: Hypertext Preprocessor).pptx
String, string builder, string buffer
New text document
stringstringbuilderstringbuffer-190830060142.pptx
Header file.pptx
Javascript objects, properties and methods .pdf
C interview-questions-techpreparation
C Interview Questions for Fresher
C interview Question and Answer
C interview-questions-techpreparation
JavaScript Objects
Module 6 - String Manipulation.pdf
13string in c#
String and string buffer
Chapter3 basic java data types and declarations
Pertemuan 6-2-sequence-diagram
Control structures i
Java String Handling
Ad

More from Renas Rekany (20)

PDF
decision making
PDF
Artificial Neural Network
PDF
AI heuristic search
PDF
AI local search
PDF
AI simple search strategies
PDF
PDF
PDF
PDF
PDF
PDF
PDF
PDF
C# with Renas
PDF
Object oriented programming inheritance
PDF
Object oriented programming
PDF
Renas Rajab Asaad
PDF
Renas Rajab Asaad
PDF
Renas Rajab Asaad
PDF
Renas Rajab Asaad
PDF
Kurdish computer skills lec1, Renas R. Rekany
decision making
Artificial Neural Network
AI heuristic search
AI local search
AI simple search strategies
C# with Renas
Object oriented programming inheritance
Object oriented programming
Renas Rajab Asaad
Renas Rajab Asaad
Renas Rajab Asaad
Renas Rajab Asaad
Kurdish computer skills lec1, Renas R. Rekany

Recently uploaded (20)

PPTX
Computer Architecture Input Output Memory.pptx
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PPTX
History, Philosophy and sociology of education (1).pptx
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PPTX
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
PPTX
B.Sc. DS Unit 2 Software Engineering.pptx
PPTX
Virtual and Augmented Reality in Current Scenario
PPTX
Introduction to Building Materials
PPTX
TNA_Presentation-1-Final(SAVE)) (1).pptx
PDF
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PDF
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
PPTX
Share_Module_2_Power_conflict_and_negotiation.pptx
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
PDF
Indian roads congress 037 - 2012 Flexible pavement
PDF
HVAC Specification 2024 according to central public works department
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
Trump Administration's workforce development strategy
Computer Architecture Input Output Memory.pptx
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
History, Philosophy and sociology of education (1).pptx
202450812 BayCHI UCSC-SV 20250812 v17.pptx
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
B.Sc. DS Unit 2 Software Engineering.pptx
Virtual and Augmented Reality in Current Scenario
Introduction to Building Materials
TNA_Presentation-1-Final(SAVE)) (1).pptx
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
Share_Module_2_Power_conflict_and_negotiation.pptx
Paper A Mock Exam 9_ Attempt review.pdf.
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
Indian roads congress 037 - 2012 Flexible pavement
HVAC Specification 2024 according to central public works department
Chinmaya Tiranga quiz Grand Finale.pdf
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Trump Administration's workforce development strategy

C# p6

  • 1. Renas R. Rekany Object-Oriented-Programming L3B 1 String Functions Definitions Clone() Make clone of string. CompareTo() Compare two strings and returns integer value as output. It returns 0 for true and 1 for false. Contains() The C# Contains method checks whether specified character or string is exists or not in the string value. EndsWith() This EndsWith Method checks whether specified character is the last character of string or not. Equals() The Equals Method in C# compares two string and returns Boolean value as output. GetHashCode() This method returns HashValue of specified string. GetType() It returns the System.Type of current instance. GetTypeCode() It returns the Stystem.TypeCode for class System.String. IndexOf() Returns the index position of first occurrence of specified character. ToLower() Converts String into lower case based on rules of the current culture. ToUpper() Converts String into Upper case based on rules of the current culture. Insert() Insert the string or character in the string at the specified position. IsNormalized() This method checks whether this string is in Unicode normalization form C. LastIndexOf() Returns the index position of last occurrence of specified character. Length It is a string property that returns length of string. Remove() This method deletes all the characters from beginning to specified index position. Replace() This method replaces the character. Split() This method splits the string based on specified value. StartsWith() It checks whether the first character of string is same as specified character. Substring() This method returns substring. ToCharArray() Converts string into char array. Trim() It removes extra whitespaces from beginning and ending of string.
  • 2. Renas R. Rekany Object-Oriented-Programming L3B 2 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string s,fn, ln; fn = textBox1.Text; ln = textBox2.Text; s = comboBox1.Text; switch (s) { case "Clone": textBox3.Text=Convert.ToString( fn.Clone()); textBox4.Text=Convert.ToString(ln.Clone()); break; case "CompareTo": int b = fn.CompareTo(ln); if (b == 0) MessageBox.Show("False"); else if (b == 1) MessageBox.Show("True"); break; case "Contains": MessageBox.Show(Convert.ToString( fn.Contains("W"))); break; case "EndsWith": MessageBox.Show(Convert.ToString( fn.EndsWith("d"))); break; case "Equals": MessageBox.Show(Convert.ToString( fn.Equals(ln))); break; case "GetHashCode": textBox3.Text =Convert.ToString( fn.GetHashCode()); textBox4.Text =Convert.ToString( ln.GetHashCode()); break; case "GetType":
  • 3. Renas R. Rekany Object-Oriented-Programming L3B 3 textBox3.Text = Convert.ToString(fn.GetType ()); textBox4.Text = Convert.ToString(ln.GetType ()); break; case "GetTypeCode": textBox3.Text = Convert.ToString(fn.GetTypeCode ()); textBox4.Text = Convert.ToString(ln.GetTypeCode ()); break; case "IndexOf": textBox3.Text = Convert.ToString(fn.IndexOf("e")); textBox4.Text = Convert.ToString(ln.IndexOf("o")); break; case "ToLower": textBox3.Text = Convert.ToString(fn.ToLower()); textBox4.Text = Convert.ToString(ln.ToLower()); break; case "ToUpper": textBox3.Text = Convert.ToString(fn.ToUpper()); textBox4.Text = Convert.ToString(ln.ToUpper()); break; case "Insert": textBox3.Text = Convert.ToString(fn.Insert(0, "Hi ")); textBox4.Text = Convert.ToString(ln.Insert(0, " Hi ")); break; case "IsNormalized": MessageBox.Show(Convert.ToString(fn.IsNormalized())); break; case "LastIndexOf": textBox3.Text = Convert.ToString(fn.LastIndexOf("o")); textBox4.Text = Convert.ToString(ln.LastIndexOf("s")); break; case "Length": textBox3.Text = Convert.ToString(fn.Length); textBox4.Text = Convert.ToString(ln.Length); break; case "Remove": textBox3.Text = Convert.ToString(fn.Remove(5)); textBox4.Text = Convert.ToString(ln.Remove(0,4)); break; case "Replace": textBox3.Text = Convert.ToString(fn.Replace("o", "*")); textBox4.Text = Convert.ToString(ln.Replace("w", "*")); break; case "Split": string[] split1 = fn.Split(new char[] { 'o' }); textBox3.Text = split1[0]; string[] split2 = ln.Split(new char[] { 'd' }); textBox4.Text = split2[1]; break; case "StartsWith": textBox3.Text=Convert.ToString(fn.StartsWith("O"));
  • 4. Renas R. Rekany Object-Oriented-Programming L3B 4 textBox4.Text = Convert.ToString(ln.StartsWith("W")); break; case "SubString": textBox3.Text = Convert.ToString(fn.Substring(2, 5)); textBox4.Text = Convert.ToString(ln.Substring(4, 5)); break; case "ToCharArray": char[] s1 = fn.ToCharArray(); char [] s2= ln.ToCharArray(); for (int i = 0; i < fn.Length; i++) { textBox3.Text = textBox3.Text + s1[i]; } for (int i = 0; i < ln.Length ; i++) { textBox4.Text = textBox4.Text + s2[i]; } break; case "Trim": textBox3.Text = Convert.ToString(fn.Trim()); textBox4.Text = Convert.ToString(ln.Trim(new char[] {'s'})); break; } } } }