UrbanPro

Learn .Net Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

What is a partial class in .NET 2.0?

Asked by Last Modified  

1 Answer

Learn .Net

Follow 1
Answer

Please enter your answer

Partial classes were introduced in .NET 2.0 as a language feature that allows a single class to be defined in multiple files. Each file contains a part of the class definition, and all the parts are combined into a single class at compile time. This feature was introduced to facilitate code organization...
read more

Partial classes were introduced in .NET 2.0 as a language feature that allows a single class to be defined in multiple files. Each file contains a part of the class definition, and all the parts are combined into a single class at compile time. This feature was introduced to facilitate code organization and separation of concerns.

Here are some key points about partial classes in .NET 2.0:

  1. Definition Syntax:

    • To create a partial class, you use the partial keyword in the class definition. Each part of the class is declared with the partial keyword, and all parts must share the same class name.
    csharp
// File 1: MyClassPart1.cs partial class MyClass { // Part 1 of the class definition public void Method1() { /* ... */ } }
csharp
  1. // File 2: MyClassPart2.cs partial class MyClass { // Part 2 of the class definition public void Method2() { /* ... */ } }
  2. Combination at Compile Time:

    • When the code is compiled, the compiler combines all the partial class definitions into a single class. The resulting class has all the members and methods from each part.
  3. Use Cases:

    • Partial classes are often used in scenarios where code generation tools or designer-generated code needs to coexist with developer-written code. For example, Windows Forms and Web Forms in Visual Studio often use partial classes to separate auto-generated UI code from user-written logic.
  4. Benefits:

    • Provides a way to organize and separate large classes into logical parts, making it easier to manage code.
    • Enables code generation scenarios where one part of the class can be auto-generated, and another part can be manually written by developers.

Here's an example illustrating a partial class in .NET 2.0:

csharp
// File 1: MyClassPart1.cs partial class MyClass { public void Method1() { /* ... */ } }
csharp
// File 2: MyClassPart2.cs partial class MyClass { public void Method2() { /* ... */ } }
csharp
// In another file or the same file // This is the combined class at compile time class Program { static void Main() { MyClass obj = new MyClass(); obj.Method1(); obj.Method2(); } }

In this example, MyClass is defined in two separate files, and at compile time, the compiler combines them into a single class. The Main method demonstrates calling methods from both parts of the class.

 
 
read less
Comments

Related Questions

Suggest some good .net mvc training in BTM .
to get basic idea about ASP .NET MVC check out the article http://www.codeproject.com/Articles/866143/Learn-MVC-Project-in-days-Day and go through their video tutorials on youtube.
Pawan
What are delegates in ASP.NET
A delegate is a class that can hold a reference to a method. Unlike other classes, a delegate class has a signature, and it can hold references only to methods that match its signature. A delegate is...
Madhuri S.
I would like to learn JQUERY and AJAX and MVC, any one have gud skills in this technologies let me know Thanks.
I am here, but can teach online only.. Please answer below things. MVC which verison? AJAX-> are you talking about .Net Ajax
Mallikarjuna
I am new to ASP.Net MVC.I need to learn ASP.Net MVC .I need an Online training course for that.Kindly suggest a good online training website for ASP.Net MVC
Hi Shubhatra.. Many materials are available online for ASP.NET MVC course. You can find many tutorials videos. Try to make small projects using those tutorials,not just read or watch them. Remember best...
Shubhabrata
How should I prepare IIt I'm in class 8th
You should start with basic programming like C & C++, this will help to make strong foundation of your career after that you could start any language training like .net, C#.net, java android etc...
Om

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

CLR [ Common Language Runtime ] and it's properties
CLR is one of the components of the .NET framework which provides an environment to execute the .NET code or the managed code. , CLR helps in converting the MSIL/CIL code into native code and running...

Format Date to “MM/dd/yyyy” in Webgrid ASP.Net MVC Razor View
Replace above line with below to apply ("DD/mm/yyyy") formatting to date field in WebGrid AllTicket.Column(columnName: "DueDate", header: "Due Date") grid.Column("Date",format:@<text> @item.Date.ToString("MM/dd/yyyy")</text>)
M

Mohammad Shafi

0 0
0

Multi-core CPU utilization using Task Parallel Library in c#
Nowadays, we are using multiple core systems. We must write our .NET applications in such a way that we must utilise the complete computing power of the machine. The parallel task library(TPL) allows...

.NET With AngularJS Training Program Syllabus
What You will Learn in .NET with AngularJS Training Program? Introduction to .Net: Features of .Net, CTS, CLS, CLR and MSIL. C# & .Net Basics and Branching & Flow Control. OOPs Concepts,...

C#.Net Interview Question and Answers
1. What is C#? C# (pronounced "C sharp") is a simple, modern, object-oriented, and type-safe programming language. It will immediately be familiar to C and C++ programmers. C#...

Recommended Articles

Hadoop is a framework which has been developed for organizing and analysing big chunks of data for a business. Suppose you have a file larger than your system’s storage capacity and you can’t store it. Hadoop helps in storing bigger files than what could be stored on one particular server. You can therefore store very,...

Read full article >

Information technology consultancy or Information technology consulting is a specialized field in which one can set their focus on providing advisory services to business firms on finding ways to use innovations in information technology to further their business and meet the objectives of the business. Not only does...

Read full article >

Whether it was the Internet Era of 90s or the Big Data Era of today, Information Technology (IT) has given birth to several lucrative career options for many. Though there will not be a “significant" increase in demand for IT professionals in 2014 as compared to 2013, a “steady” demand for IT professionals is rest assured...

Read full article >

Software Development has been one of the most popular career trends since years. The reason behind this is the fact that software are being used almost everywhere today.  In all of our lives, from the morning’s alarm clock to the coffee maker, car, mobile phone, computer, ATM and in almost everything we use in our daily...

Read full article >

Looking for .Net Training ?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for .Net Training Classes?

The best tutors for .Net Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn .Net Training with the Best Tutors

The best Tutors for .Net Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more