---
title: "What is difference between Prop and Attribute in C#?"  
description: "What is difference between Prop and Attribute in C#?"  
author: "Hemant Patel"  
published: 2017-03-03  
updated: 2020-09-19  
canonical: https://www.mindstick.com/interview/23220/what-is-difference-between-prop-and-attribute-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# What is difference between Prop and Attribute in C#?

There is lots of difference between them. A property lets you get/set data in your class. And an attribute is much different, “an attribute is additional declarative information that is specified for a declaration.”

\
**Example of Property in C#:**

```
public class Employee{    public string Name { get; set; }    public string Email { get; set; }    public string Address { get; set; }}
```

## Example of Attribute in C#:

```
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks; namespace Learn{    class Program    {        [Obsolete("Don't use Old method, use New method", true)]        static void Old()        {            Console.WriteLine("New method executed");            Console.ReadLine();        }         static void New()         {            Console.WriteLine("New method executed");            Console.ReadLine();        }         public static void Main()        {            New();        }    }}
```

## Answers

### Answer by Hemant Patel

There is lots of difference between them. A property lets you get/set data in your class. And an attribute is much different, “an attribute is additional declarative information that is specified for a declaration.”

\
**Example of Property in C#:**

```
public class Employee{    public string Name { get; set; }    public string Email { get; set; }    public string Address { get; set; }}
```

## Example of Attribute in C#:

```
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks; namespace Learn{    class Program    {        [Obsolete("Don't use Old method, use New method", true)]        static void Old()        {            Console.WriteLine("New method executed");            Console.ReadLine();        }         static void New()         {            Console.WriteLine("New method executed");            Console.ReadLine();        }         public static void Main()        {            New();        }    }}
```


---

Original Source: https://www.mindstick.com/interview/23220/what-is-difference-between-prop-and-attribute-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
