Najam Sikander Awan
logs of my work and digital life
logs of my work and digital life
Jan 25th
I have been clearing my concepts regarding inheritance and investigating if parent reference variable can point to child class object and vice versa.
namespace oops
{
public class A
{
public A()
{
Console.WriteLine("A");
Console.WriteLine("===============================");
}
public void Add()
{
Console.WriteLine("Add");
}
}
public class B : A
{
public B()
{
Console.WriteLine("B");
Console.WriteLine("===============================");
}
public void Sub()
{
Console.WriteLine("Sub");
}
}
class Program
{
static void Main(string[] args)
{
A objA = new A();
B objB = objA as B;
A objAB = new B();
B objBB = objAB as B;
objBB.Sub();
if (objB is B)
{
objB.Add();
}
else
{
Console.WriteLine("objB is not B");
}
//objA.Add();
Console.ReadLine();
}
}
}
Out put of the code is
===============================
A
===============================
B
===============================
Sub
objB is not B
Jul 20th
List the remote branches that exist for a repository you have cloned:
git remote show origin
Create a local branch that tracks one of the remote branches and then use that local branch:
git checkout –track -b name_of_local_branch origin/name_of_remote_branch
If you have not done a pull since someone else created the remote branch, you may first need to do:
git fetch
Remove branch from repo.
Ex:
removes somebranch
Jul 9th
I have uploaded another static website that might become an e-commerce website in future.
Jul 8th
Hi Guys,
I am reading more on design patterns from this article after little theory session here is working code. Key point was all of the collection classes in the System.Collections namespace, as well as arrays, implement IEnumerable and can therefore be iterated over.
namespace ConsoleApplication1
{
class IteratorPattern
{
static void Main(string[] args)
{
int[] values = new int[] { 1, 2, 3, 4, 5 };
IEnumerator<int> e = ((IEnumerable<int>)values).GetEnumerator();
while (e.MoveNext())
{
Console.Write(e.Current.ToString() + " ");
}
Console.ReadKey();
}
}
}
Jul 8th
Hi folks,
Well I am investigating design patterns by reading an article so after reading a bit I thought it would be nice if I write some code and test it.
namespace ConsoleApplication1
{
class Program
{
/// <summary>
/// Product Class
/// </summary>
public class Product
{
public delegate void NameChangeEventHandler(int a);
public event NameChangeEventHandler NameChanged;
private string _name;
public string Name
{
get
{
return _name;
}
set
{
_name = value;
if (NameChanged != null)
{
NameChanged(5);
}
}
}
public Product(string name)
{
Name = name;
}
public void PrintName()
{
Console.WriteLine("ProductName={0}", Name);
}
}
/// <summary>
/// Test Class
/// </summary>
public class Test
{
public Test(Product P)
{
P.NameChanged += new Product.NameChangeEventHandler(ChangeDetected);
}
public void ChangeDetected(int a)
{
Console.WriteLine("change found,argument passed is {0}",a);
}
}
static void Main(string[] args)
{
Product p = new Product("najam awan");
p.PrintName();
Test t = new Test(p);
p.Name = "najaf awan";
p.PrintName();
Console.ReadKey();
}
}
}
Jul 6th
I was reading how to write events for your custom classes so after reading a little I thought give it a shot and created this sample code. Below code is using Product class with event and delegate for event handling and other class named Test is using this class and manipulate product class data. If you change the Name of the product event will fire.
namespace ConsoleApplication1
{
class Program
{
/// <summary>
/// Product Class
/// </summary>
public class Product
{
public delegate void NameChangeEventHandler(int a);
public event NameChangeEventHandler NameChanged;
private string _name;
public string Name
{
get
{
return _name;
}
set
{
_name = value;
if (NameChanged != null)
{
NameChanged(5);
}
}
}
public Product(string name)
{
Name = name;
}
public void PrintName()
{
Console.WriteLine("ProductName={0}", Name);
}
}
/// <summary>
/// Test Class
/// </summary>
public class Test
{
public void ChangeDetected(int a)
{
Console.WriteLine("change found,argument passed is {0}",a);
}
public void TestProduct()
{
Product p = new Product("najam awan");
p.PrintName();
p.NameChanged += ChangeDetected;
p.Name = "najaf";
p.PrintName();
Console.ReadKey();
}
}
static void Main(string[] args)
{
Test t = new Test();
t.TestProduct();
}
}
}
Jun 29th
Hello
I have came across to this wonderful blog post that show in details how to call javascript functions using different ways its a must read article even if you are not good in javascript please read article at
http://devlicio.us/blogs/sergio_pereira/archive/2009/02/09/javascript-5-ways-to-call-a-function.aspx