We have already discussed the variables in detail so I hope that you must have the idea of what variables are and if you don't then you must read the previous tutorials first. The code is also given below in the tutorial. So, let's get started with How to use C# String Variables:
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 Variables
{
public partial class Form1 : Form
{
string webBlog;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void ClickHere_Click(object sender, EventArgs e)
{
webBlog = "www.TheEngineeringProjects.com";
txtClick.Text = webBlog;
}
}
}
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 Variables
{
public partial class Form1 : Form
{
string webBlog1, webBlog2;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void ClickHere_Click(object sender, EventArgs e)
{
webBlog1 = "www.TheEngineeringProjects.com";
webBlog2 = "www.TheEngineeringProjects.com";
if (String.Compare(webBlog1, webBlog2) == 0)
{
txtClick.Text = "Both are equal";
}
else
{
txtClick.Text = "Both are not equal";
}
}
}
}
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 Variables
{
public partial class Form1 : Form
{
string webBlog1, webBlog2;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void ClickHere_Click(object sender, EventArgs e)
{
webBlog1 = "www.TheEngineeringProjects.com";
if (webBlog1.Contains("Projects"))
{
txtClick.Text = "Its present in string";
}
else
{
txtClick.Text = "Its not present in string.";
}
}
}
}
So, that's all about C# String Variable. I hope you guys have learned something out of it. that's all for today. In the next tutorial we will learn more about C#. Till then take care and have fun !!! :)
JLCPCB – Prototype 10 PCBs for $2 (For Any Color)
China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
How to Get PCB Cash Coupon from JLCPCB: https://bit.ly/2GMCH9w