This is a test
- 52 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
eBook - ePub
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
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
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)
Fig 1
Fig 1
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)
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
- Preface
- Introduction
- Practical exercises
- How to create a class
- Declaration of a class in C#