The basic concepts of OOP in C#
eBook - ePub

The basic concepts of OOP in C#

Learn conceptually in simple language

  1. 52 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

The basic concepts of OOP in C#

Learn conceptually in simple language

Book details
Book preview
Table of contents
Citations

About This Book

This book helps interested audiences to get familiar with the basics of the object-oriented programming paradigm in C# faster, for the author has written this book in the simple language, used extremely simple examples; however, being at least junior level in C#.Net is preferred. Moreover, the important points have emboldened and underlined too.

Frequently asked questions

Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes, you can access The basic concepts of OOP in C# by Hani Marzban in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming in C#. We have over one million books available in our catalogue for you to explore.

Information

Year
2019
ISBN
9783966612555

How to create a class

Open the Visual studio software then click on File New Project Visual C# Console Application, and after changing the name of the project and also the location (optional), click on “OK” button. (Fig 1)
Image
Fig 1
Fig 1
Image
Great, we need to add a class to the project, find the project name in the solution explorer window and do a right click on it and follow, Add Class. (Fig 2)
Fig 2
Fig 2
Good, so a new window will be opened as seen in below, containing different items, but what we need, is “class” item, so firstly click on “Visual C# Items” then choose “Class.”
Finally, it is possible to change the name of the class too, and then click on “Ok” button to create it. (Fig 3)
Image
Yes, we did it. We could add a class file to our project successfully. Since now, we can double-click on it to open the file and begin to create different classes.
Fig 3
Fig 3

Declaration of a class in C#

[Access modifier][“class” keyword][ClassName]
On second thought, “Access modifier” you need to replace items, which mentioned below,
public: The type or member could become accessible by any other code in the same assembly or another assembly that references it.
internal: The type or member could become accessible by any code in the same assembly, but not from another assembly.
After [Access modifier], you have to put the “class” keyword, and then a name for your class, please see the example below to see how it works. (Using access modifiers is an option).
Note:Internal” is the default if no access modifier is specified.
public / internal class Customer
{
Codes go here…
}
So, try to create a class in C# to see the way it works; however, it makes a default class when we add a class file to our project, but rely on putting some classes to understand essential structure.

Declaration of a method in C#

[Access modifier][Return type][Method Name]([Parameters])
Well, methods are defining inside a class, by this, firstly, we need to have a class. Imagine we have a class named “math_operation”, and I am going to create a method inside this class as “sum”. Before of everything, let us explain the elements of declaration line in below.
Instead of, “Access modifier” you can replace items, which mentioned below.
public: The type or member could become accessible by any other code in the same assembly or another assembly that references it.
private: The type or member could become accessible only by code in the same class or struct.
protected: The type or member could become accessible only by code in the same class, or in a class, which derived from that class.
internal: The type or member could become accessible by any code in the same assembly, but not from another assembly.
protected internal: The type or member could become accessible by any code in the assembly, which it is declared, or from a derived class in another assembly.
private protected: The type or member could become accessible only within its declaring assembly, by code in the same class or in a type that has derived from that class.
Rather “return type,” if the method returns any value, you have to write the data type, which method returns such as “int”, “string”, and etcetera. Else, the return type is void, and we need to apply “void” keyword.
Note: If we put “void” keyword as a substitute for “return type,” you will not need to write “return” keyword inside the body of the method, but if you use any data type in “return type” then you will need to employ the “return” keyword.
On behalf of, “Method name...

Table of contents

  1. Preface
  2. Introduction
  3. Practical exercises
  4. How to create a class
  5. Declaration of a class in C#