c sharp programming code examples
Example 1: c# code examples
using System;
#region Studio Style
class Program : IThemeable
{
static int _I = 1;
delegate void DoSomething();
static void Main(string[] args)
{
string normalStr = "The time now is approximately " + DateTime.Now;
Uri Illegal1Uri = new Uri("http://packmyboxwith/jugs.html?q=five-dozen&t=liquor");
Regex OperatorRegex = new Regex(@"\S#$", RegexOptions.IgnorePatternWhitespace);
for (int O = 0; O < 123456789; O++)
{
_I += (O % 3) * ((O / 1) ^ 2) - 5;
if (!OperatorRegex.IsMatch(Illegal1Uri.ToString()))
{
Console.WriteLine(Illegal1Uri + normalStr);
}
}
}
}
#endregion
Example 2: c# code examples
using System;
namespace RectangleApplication {
class Rectangle {
double length;
double width;
public void Acceptdetails() {
length = 4.5;
width = 3.5;
}
public double GetArea() {
return length * width;
}
public void Display() {
Console.WriteLine("Length: {0}", length);
Console.WriteLine("Width: {0}", width);
Console.WriteLine("Area: {0}", GetArea());
}
}
class ExecuteRectangle {
static void Main(string[] args) {
Rectangle r = new Rectangle();
r.Acceptdetails();
r.Display();
Console.ReadLine();
}
}
}