Abalfazl
May 2nd, 2008, 09:10 AM
Hello!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace sepehr
{
class zarb
{
public int i=10;
int j=100;
public void zarb1()
{
i = i *j;
}
public int zarb2
{
get { return i; }
}
}
class test
{
static void Main(string[] args)
{
zarb k= new zarb();
Console.WriteLine(k.zarb2);
Console.ReadLine();
}
}
}
1-I expect it shows 1000,but it shows 10,
why?
2-I use this :
public int zarb2
{
get { return i; }
}
}
Is it possible I don't use get{ return i;},instead of that I use
class test
{
static void Main(string[] args)
{
zarb k= new zarb();
Console.WriteLine(k.i);
Console.ReadLine();
}
another question:
using System;
class Unary
{
public static void Main()
{
int unary = 0;
int preIncrement;
int preDecrement;
int postIncrement;
int postDecrement;
int positive;
int negative;
sbyte bitNot;
bool logNot;
preIncrement = ++unary;
Console.WriteLine("pre-Increment: {0}", preIncrement);
preDecrement = --unary;
Console.WriteLine("pre-Decrement: {0}", preDecrement);
postdecrement = unary--;
Console.WriteLine("Post-Decrement: {0}", postDecrement);
why does it use "{0}"?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace sepehr
{
class zarb
{
public int i=10;
int j=100;
public void zarb1()
{
i = i *j;
}
public int zarb2
{
get { return i; }
}
}
class test
{
static void Main(string[] args)
{
zarb k= new zarb();
Console.WriteLine(k.zarb2);
Console.ReadLine();
}
}
}
1-I expect it shows 1000,but it shows 10,
why?
2-I use this :
public int zarb2
{
get { return i; }
}
}
Is it possible I don't use get{ return i;},instead of that I use
class test
{
static void Main(string[] args)
{
zarb k= new zarb();
Console.WriteLine(k.i);
Console.ReadLine();
}
another question:
using System;
class Unary
{
public static void Main()
{
int unary = 0;
int preIncrement;
int preDecrement;
int postIncrement;
int postDecrement;
int positive;
int negative;
sbyte bitNot;
bool logNot;
preIncrement = ++unary;
Console.WriteLine("pre-Increment: {0}", preIncrement);
preDecrement = --unary;
Console.WriteLine("pre-Decrement: {0}", preDecrement);
postdecrement = unary--;
Console.WriteLine("Post-Decrement: {0}", postDecrement);
why does it use "{0}"?