Click here to Skip to main content
15,889,826 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# Creating a class and assigning properties to it. Pin
Darrall23-Dec-09 15:49
Darrall23-Dec-09 15:49 
GeneralRe: C# Creating a class and assigning properties to it. Pin
Luc Pattyn23-Dec-09 16:06
sitebuilderLuc Pattyn23-Dec-09 16:06 
GeneralRe: C# Creating a class and assigning properties to it. Pin
Darrall24-Dec-09 4:26
Darrall24-Dec-09 4:26 
AnswerRe: C# Creating a class and assigning properties to it. Pin
#realJSOP23-Dec-09 21:56
mve#realJSOP23-Dec-09 21:56 
GeneralRe: C# Creating a class and assigning properties to it. Pin
Darrall24-Dec-09 4:52
Darrall24-Dec-09 4:52 
AnswerRe: C# Creating a class and assigning properties to it. Pin
Richard MacCutchan23-Dec-09 22:28
mveRichard MacCutchan23-Dec-09 22:28 
GeneralRe: C# Creating a class and assigning properties to it. Pin
Darrall24-Dec-09 4:59
Darrall24-Dec-09 4:59 
AnswerRe: C# Creating a class and assigning properties to it. Pin
hamed-vojdani24-Dec-09 5:27
hamed-vojdani24-Dec-09 5:27 
I don't understand your question completely but this may be help Smile | :)


1- C# is case sensitive , mean that double Radius; and public double radius are not same.

2- Properties is not variable, it's a way for set or get a variable , and variable can be different type from it's properties like:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace circle
{
    class circle
    {
        double Radius;
        public string radius
        {
            get 
            {
                return Radius.ToString(); 
            }
            set 
            {
                double i = -1;
                if (double.TryParse(value, out i))
                {
                    Radius = i;
                }                
            }
        }

        public string Circumference
        {
            get
            {
                return (2 * Math.PI * Radius).ToString("N6");
            }
        }
    }

    class MyApp
    {
        public static void Main()
        {
            circle myCircle = new circle();
            myCircle.radius = Console.ReadLine();

            Console.WriteLine("Radius: = {0}", myCircle.radius);
            Console.WriteLine("Circumference: = {0}", myCircle.Circumference);

        }
    }
}


3- Properties is not only for return existing variable, it can do process for calculating or formatting return value like Circumference properties in above code

4- Properties can be readonly like Circumference properties which you can not set a value for it

Hope helps with this ugly sample code Wink | ;)
GeneralRe: C# Creating a class and assigning properties to it. Pin
Darrall24-Dec-09 5:39
Darrall24-Dec-09 5:39 
QuestionCondense a list Pin
o m n i23-Dec-09 11:57
o m n i23-Dec-09 11:57 
AnswerRe: Condense a list Pin
Luc Pattyn23-Dec-09 12:07
sitebuilderLuc Pattyn23-Dec-09 12:07 
GeneralRe: Condense a list Pin
o m n i23-Dec-09 12:32
o m n i23-Dec-09 12:32 
QuestionGeneral issue: When application doesn't have focus, and you click a button on it, it doesn't register.... Pin
sherifffruitfly23-Dec-09 11:03
sherifffruitfly23-Dec-09 11:03 
AnswerRe: General issue: When application doesn't have focus, and you click a button on it, it doesn't register.... Pin
Ravi Bhavnani23-Dec-09 14:01
professionalRavi Bhavnani23-Dec-09 14:01 
QuestionReflection Get Access Modifier Pin
dataminers23-Dec-09 9:02
dataminers23-Dec-09 9:02 
AnswerRe: Reflection Get Access Modifier Pin
Luc Pattyn23-Dec-09 9:45
sitebuilderLuc Pattyn23-Dec-09 9:45 
GeneralRe: Reflection Get Access Modifier Pin
dataminers24-Dec-09 0:50
dataminers24-Dec-09 0:50 
Questioncan i dynamicly access object from name of object Pin
combo_ci23-Dec-09 6:20
combo_ci23-Dec-09 6:20 
AnswerRe: can i dynamicly access object from name of object Pin
Jordon4Kraftd23-Dec-09 10:13
Jordon4Kraftd23-Dec-09 10:13 
GeneralRe: can i dynamicly access object from name of object Pin
combo_ci23-Dec-09 18:49
combo_ci23-Dec-09 18:49 
GeneralRe: can i dynamicly access object from name of object Pin
Luc Pattyn24-Dec-09 0:48
sitebuilderLuc Pattyn24-Dec-09 0:48 
AnswerRe: can i dynamicly access object from name of object Pin
softty24-Dec-09 0:22
softty24-Dec-09 0:22 
QuestionHow to show all surfaces of a cube? Pin
whiteclouds23-Dec-09 4:48
whiteclouds23-Dec-09 4:48 
Questionhow to create 2 threads on on diferent procesors Pin
Renven23-Dec-09 3:29
Renven23-Dec-09 3:29 
AnswerRe: how to create 2 threads on on diferent procesors [modified] Pin
#realJSOP23-Dec-09 4:31
mve#realJSOP23-Dec-09 4:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.