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

Hi sir, I'm confused between .net and java. What to choose for a career. I have little bit knowledge of asp.net. Please guide me for this. Thank you
Hello Kirit, The application which were devloped about 2 decades back was mostly coded in java and so you will see so many of the application (in several company and outside) written in java. .Net(collectively...
Kirit
Which is the best institute for .net ajax in Pune?
Ajax is simple concept. You really dont need any training institutes.
Aditya
What is dot net MVC?
It is a design pattern. .NET MVC is a successful template above asp.net framework. .NET MVC is used to develop web applications from the scratch
Tina
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
What is the difference between asp.net and vb.net?
asp.net is web technology that is used in building web applications and websites. Vb.net is language that is used in writing programs that are utilizing the asp.net framework Asp.net contains...
Aadarsh

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

Ask a Question

Related Lessons

ASP .Net Interview Questions.
1. What is ASP? Active Server Pages (ASP), also known as Classic ASP, is a Microsoft's server-side technology, which helps in creating dynamic and user-friendly Web pages. It uses different scripting...

Trends in .Net Platform
.NET Framework is a software framework developed by Microsoft. It includes a large class library named Framework Class Library (FCL) and provides language interoperability (each language can use code written...

Steps to fill drop-down value from database to view page in ASP.Net MVC Application
In simple few steps you can fill the dynamic data from database to HTML page in MVC Application Write connection string in web config file Create table related getter setter in model Fetch data...

Working with Delegates & Events in .NET
Events & Delegates A delegate is a reference type derived from the System.Delegate class which can be used to call methods of same matching signature.As you all know signature of a method is defined...

Difference between App services,Cloud Service and Virtual Machine in Microsoft Azure
App Services :When you want to deploy your application to Azure IIS conatainers without requiring any control,web apps should be preferred.It's a part of Azure Paas.1) When you need IIS.2) Satisfy with...

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