Tuesday, July 8, 2014

C# Tutorial for Beginners 22 - Properties in C# (How to Define Properti...









1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
namespace MyProject.Examples
{
    public class Book
    {
        private int _id;
        private string _bookName;
        private int _noOfPAges=250;
        private string _auther;

  
        public string Auther{get; set;}
            

        public int Id
        {
            set
            {
                if (value < 0)
                    throw new Exception("Id not valid");
                this._id = value;
            }
            get {
                return this._id;
            }
        }
  


        public string BookName
        {
            set
            {
                if (string.IsNullOrEmpty(value))
                    throw new Exception("Book Name not valid or null");
                this._bookName = value;
            }
            get {
                return this._bookName;
            }
        }


        public int NoOfPAge
        {
            get
            {
                return this._noOfPAges;
            }
        }
    }
 

    class ExampleOne
    {
        public static void Main()
        {
         
            Book B1 =new Book();
            B1.Id=10;
            B1.BookName = "The C# Book";
            B1.Auther = "ProgrammingKnowldge";
            Console.WriteLine("The Book Id is {0}", B1.Id);
            Console.WriteLine("The Book Name is {0}", B1.BookName);
            Console.WriteLine("The Book Page is {0}", B1.NoOfPAge);
            Console.WriteLine("The Book Auther is {0}", B1.Auther);
            Console.ReadKey();
        }
    }
}














---------------------------------------------------------------------

earches related to properties c#

extension properties c#

use properties c#

writing properties in c#

override properties c#

private properties c#

class properties c#

properties.settings c#

constructor c#

Searches related to property c#

automatic property c#

virtual property c#

nonserialized property c#

property c# interface

property c# default value

override property c#

private set property c#

private property c#

Using Properties (C# Programming Guide)
IT Certification Category (English)640x480

Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com


Top Online Courses From ProgrammingKnowledge

Python Course http://bit.ly/2vsuMaS
Java Coursehttp://bit.ly/2GEfQMf
Bash Coursehttp://bit.ly/2DBVF0C
Linux Coursehttp://bit.ly/2IXuil0
C Course http://bit.ly/2GQCiD1
C++ Coursehttp://bit.ly/2V4oEVJ
PHP Coursehttp://bit.ly/2XP71WH
Android Coursehttp://bit.ly/2UHih5H
C# Coursehttp://bit.ly/2Vr7HEl
JavaFx Coursehttp://bit.ly/2XMvZWA
NodeJs Coursehttp://bit.ly/2GPg7gA
Jenkins Course http://bit.ly/2Wd4l4W
Scala Coursehttp://bit.ly/2PysyA4
Bootstrap Coursehttp://bit.ly/2DFQ2yC
MongoDB Coursehttp://bit.ly/2LaCJfP
QT C++ GUI Coursehttp://bit.ly/2vwqHSZ