SlideShare a Scribd company logo
1 of 4
Download to read offline
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

What's hot (20)

Pointer basics
Pointer basicsPointer basics
Pointer basics
 
R programming Language
R programming LanguageR programming Language
R programming Language
 
Loops in Python
Loops in PythonLoops in Python
Loops in Python
 
Python-02| Input, Output & Import
Python-02| Input, Output & ImportPython-02| Input, Output & Import
Python-02| Input, Output & Import
 
Introduction To Programming with Python-3
Introduction To Programming with Python-3Introduction To Programming with Python-3
Introduction To Programming with Python-3
 
Iteration, induction, and recursion
Iteration, induction, and recursionIteration, induction, and recursion
Iteration, induction, and recursion
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Jsp session 12
Jsp   session 12Jsp   session 12
Jsp session 12
 
Introduction to Python
Introduction to Python  Introduction to Python
Introduction to Python
 
Python advance
Python advancePython advance
Python advance
 
DEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World HaskellDEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World Haskell
 
Introduction to Python - Part Two
Introduction to Python - Part TwoIntroduction to Python - Part Two
Introduction to Python - Part Two
 
Python language data types
Python language data typesPython language data types
Python language data types
 
Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursion
 
C faqs interview questions placement paper 2013
C faqs interview questions placement paper 2013C faqs interview questions placement paper 2013
C faqs interview questions placement paper 2013
 
Software Craftsmanship - 2
Software Craftsmanship - 2Software Craftsmanship - 2
Software Craftsmanship - 2
 
2.2 higher order-functions
2.2 higher order-functions2.2 higher order-functions
2.2 higher order-functions
 
Python lists
Python listsPython lists
Python lists
 
Programming with Python
Programming with PythonProgramming with Python
Programming with Python
 
Ruby basics || updated
Ruby basics || updatedRuby basics || updated
Ruby basics || updated
 

Similar to C# p6

New text document
New text documentNew text document
New text documentTam Ngo
 
stringstringbuilderstringbuffer-190830060142.pptx
stringstringbuilderstringbuffer-190830060142.pptxstringstringbuilderstringbuffer-190830060142.pptx
stringstringbuilderstringbuffer-190830060142.pptxssuser99ca78
 
C Interview Questions for Fresher
C Interview Questions for FresherC Interview Questions for Fresher
C Interview Questions for FresherJaved Ahmad
 
C interview-questions-techpreparation
C interview-questions-techpreparationC interview-questions-techpreparation
C interview-questions-techpreparationsonu sharma
 
C interview-questions-techpreparation
C interview-questions-techpreparationC interview-questions-techpreparation
C interview-questions-techpreparationKgr Sushmitha
 
JavaScript Objects
JavaScript ObjectsJavaScript Objects
JavaScript ObjectsReem Alattas
 
Module 6 - String Manipulation.pdf
Module 6 - String Manipulation.pdfModule 6 - String Manipulation.pdf
Module 6 - String Manipulation.pdfMegMeg17
 
13string in c#
13string in c#13string in c#
13string in c#Sireesh K
 
String and string buffer
String and string bufferString and string buffer
String and string bufferkamal kotecha
 
Chapter3 basic java data types and declarations
Chapter3 basic java data types and declarationsChapter3 basic java data types and declarations
Chapter3 basic java data types and declarationssshhzap
 
Pertemuan 6-2-sequence-diagram
Pertemuan 6-2-sequence-diagramPertemuan 6-2-sequence-diagram
Pertemuan 6-2-sequence-diagramAbi Bobon
 
Control structures i
Control structures i Control structures i
Control structures i Ahmad Idrees
 
Java scanner, everything you need to know about Java Scanner
Java scanner, everything you need to know about Java ScannerJava scanner, everything you need to know about Java Scanner
Java scanner, everything you need to know about Java ScannerEdward Nyang'ali
 

Similar to C# p6 (20)

C# p5
C# p5C# p5
C# p5
 
String, string builder, string buffer
String, string builder, string bufferString, string builder, string buffer
String, string builder, string buffer
 
New text document
New text documentNew text document
New text document
 
stringstringbuilderstringbuffer-190830060142.pptx
stringstringbuilderstringbuffer-190830060142.pptxstringstringbuilderstringbuffer-190830060142.pptx
stringstringbuilderstringbuffer-190830060142.pptx
 
Header file.pptx
Header file.pptxHeader file.pptx
Header file.pptx
 
easyPy-Basic.pdf
easyPy-Basic.pdfeasyPy-Basic.pdf
easyPy-Basic.pdf
 
C Interview Questions for Fresher
C Interview Questions for FresherC Interview Questions for Fresher
C Interview Questions for Fresher
 
C interview-questions-techpreparation
C interview-questions-techpreparationC interview-questions-techpreparation
C interview-questions-techpreparation
 
C interview-questions-techpreparation
C interview-questions-techpreparationC interview-questions-techpreparation
C interview-questions-techpreparation
 
C interview Question and Answer
C interview Question and AnswerC interview Question and Answer
C interview Question and Answer
 
JavaScript Objects
JavaScript ObjectsJavaScript Objects
JavaScript Objects
 
Module 6 - String Manipulation.pdf
Module 6 - String Manipulation.pdfModule 6 - String Manipulation.pdf
Module 6 - String Manipulation.pdf
 
13string in c#
13string in c#13string in c#
13string in c#
 
String and string buffer
String and string bufferString and string buffer
String and string buffer
 
Chapter3 basic java data types and declarations
Chapter3 basic java data types and declarationsChapter3 basic java data types and declarations
Chapter3 basic java data types and declarations
 
Strings
StringsStrings
Strings
 
Pertemuan 6-2-sequence-diagram
Pertemuan 6-2-sequence-diagramPertemuan 6-2-sequence-diagram
Pertemuan 6-2-sequence-diagram
 
Control structures i
Control structures i Control structures i
Control structures i
 
Java String Handling
Java String HandlingJava String Handling
Java String Handling
 
Java scanner, everything you need to know about Java Scanner
Java scanner, everything you need to know about Java ScannerJava scanner, everything you need to know about Java Scanner
Java scanner, everything you need to know about Java Scanner
 

More from Renas Rekany

More from Renas Rekany (20)

decision making
decision makingdecision making
decision making
 
Artificial Neural Network
Artificial Neural NetworkArtificial Neural Network
Artificial Neural Network
 
AI heuristic search
AI heuristic searchAI heuristic search
AI heuristic search
 
AI local search
AI local searchAI local search
AI local search
 
AI simple search strategies
AI simple search strategiesAI simple search strategies
AI simple search strategies
 
C# p9
C# p9C# p9
C# p9
 
C# p8
C# p8C# p8
C# p8
 
C# p7
C# p7C# p7
C# p7
 
C# p4
C# p4C# p4
C# p4
 
C# p3
C# p3C# p3
C# p3
 
C# p2
C# p2C# p2
C# p2
 
C# p1
C# p1C# p1
C# p1
 
C# with Renas
C# with RenasC# with Renas
C# with Renas
 
Object oriented programming inheritance
Object oriented programming inheritanceObject oriented programming inheritance
Object oriented programming inheritance
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Renas Rajab Asaad
Renas Rajab Asaad Renas Rajab Asaad
Renas Rajab Asaad
 
Renas Rajab Asaad
Renas Rajab AsaadRenas Rajab Asaad
Renas Rajab Asaad
 
Renas Rajab Asaad
Renas Rajab Asaad Renas Rajab Asaad
Renas Rajab Asaad
 
Renas Rajab Asaad
Renas Rajab Asaad Renas Rajab Asaad
Renas Rajab Asaad
 
Kurdish computer skills lec1, Renas R. Rekany
Kurdish computer skills lec1, Renas R. RekanyKurdish computer skills lec1, Renas R. Rekany
Kurdish computer skills lec1, Renas R. Rekany
 

Recently uploaded

Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 

Recently uploaded (20)

Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 

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; } } } }