# AttributeTargets

***

**1. Assembly-Level Attributes**

```csharp
[assembly: AssemblyCopyright("Copyright 2023, MyCompany")]
```

**2. Type-Level Attributes**

```csharp
[Serializable]
public class MyClass
{
    // ...
}
```

**3. Method-Level Attributes**

```csharp
[Obsolete("Use the newMethod() method instead.")]
public void oldMethod()
{
    // ...
}
```

**4. Property-Level Attributes**

```csharp
[JsonIgnore]
public string Password { get; set; }
```

**5. Field-Level Attributes**

```csharp
[NonSerialized]
private int myPrivateField;
```

**6. Parameter-Level Attributes**

```csharp
public void MyMethod([Optional] string name)
{
    // ...
}
```

**7. Event-Level Attributes**

```csharp
[Browsable(false)]
public event EventHandler MyEvent;
```

**8. Type Parameter-Level Attributes**

```csharp
public class MyGenericClass<T> where T : class, new()
{
    // ...
}
```

**9. Method Parameter Parameter-Level Attributes**

```csharp
public void MyMethod(params [Required] string[] names)
{
    // ...
}
```

**10. Return Value-Level Attributes**

```csharp
[return: MarshalAs(UnmanagedType.Bool)]
public bool MyMethod()
{
    // ...
}
```

**11. Attribute Usage Attribute**

```csharp
[AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = true)]
public class MyCustomAttribute : Attribute
{
    // ...
}
```

**12. Enum Member-Level Attributes**

```csharp
public enum MyEnum
{
    [Description("Small size")]
    Small = 1,

    [Description("Medium size")]
    Medium = 2,

    [Description("Large size")]
    Large = 3
}
```

**13. Delegate-Level Attributes**

```csharp
[ComVisible(true)]
public delegate void MyDelegate();
```

**14. Interface-Level Attributes**

```csharp
[Guid("F4368519-C692-4290-AB63-D2763B5A50C7")]
public interface IMyInterface
{
    // ...
}
```

**15. Class Member-Level Attributes**

```csharp
[DataMember]
public string Name { get; set; }
```

**16. Constructor-Level Attributes**

```csharp
[CLSCompliant(false)]
public MyConstructor()
{
    // ...
}
```

**17. Type Parameter Constraint-Level Attributes**

```csharp
public class MyGenericClass<T> where T : struct, IComparable
{
    // ...
}
```

**18. Anonymous Type-Level Attributes**

```csharp
var myAnonymousType = new { myProperty = "value" };
```

**19. Lambda Expression-Level Attributes**

```csharp
Func<int, int> myLambda = x => x + 1;
```

**20. Attribute Targets Attribute Usage**

```csharp
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
public class MyCustomAttribute : Attribute
{
    // ...
}
```

**21. Field-Like Event-Level Attributes**

```csharp
public event EventHandler MyEventHandler;
```

**22. Property Parameter-Level Attributes**

```csharp
public string MyProperty { get; [Required] set; }
```

**23. Event Parameter-Level Attributes**

```csharp
public event EventHandler<EventArgs> MyEventHandler;
```

**24. Assembly Product-Level Attributes**

```csharp
[assembly: AssemblyProduct("MyProduct")]
```

**25. Assembly Description-Level Attributes**

```csharp
[assembly: AssemblyDescription("MyProduct is a software that does X, Y and Z.")]
```

**26. Assembly Configuration-Level Attributes**

```csharp
[assembly: AssemblyConfiguration("Debug")]
```

**27. Assembly Title-Level Attributes**

```csharp
[assembly: AssemblyTitle("MyProduct")]
```

**28. Assembly Company-Level Attributes**

```csharp
[assembly: AssemblyCompany("MyCompany")]
```

**29. Pointer-Level Attributes**

```csharp
public unsafe int* MyPointer;
```

**30. Fixed-Level Attributes**

```csharp
public unsafe fixed int myArray[10];
```

**31. Custom Attribute-Level Attributes**

```csharp
[MyCustomAttribute("MyValue")]
public class MyClass
{
    // ...
}
```

**32. Assembly Informational Version-Level Attributes**

```csharp
[assembly: AssemblyInformationalVersion("1.0.0")]
```

**33. Assembly File Version-Level Attributes**

```csharp
[assembly: AssemblyFileVersion("1.0.0.0")]
```

**34. Assembly Version-Level Attributes**

```csharp
[assembly: AssemblyVersion("1.0.0.0")]
```

**35. Assembly Culture-Level Attributes**

```csharp
[assembly: AssemblyCulture("")]
```

**36. Assembly Neutral Culture-Level Attributes**

```csharp
[assembly: AssemblyCulture("")]
```

**37. Event Field-Level Attributes**

```csharp
public event EventHandler MyEvent;
```

**38. Assembly Delay Sign-Level Attributes**

```csharp
[assembly: AssemblyDelaySign(false)]
```

**39. Assembly Key File-Level Attributes**

```csharp
[assembly: AssemblyKeyFile("MyKeyFile.snk")]
```

**40. Assembly Strong Name Signed-Level Attributes**

```csharp
[assembly: AssemblyKeyName("")]
```

**41. Assembly Signature-Level Attributes**

```csharp
[assembly: AssemblySignature("")]
```

**42. Assembly Default Alias-Level Attributes**

```csharp
[assembly: AssemblyDefaultAlias("MyAssembly")]
```

**43. Assembly License-Level Attributes**

```csharp
[assembly: AssemblyLicense("Copyright 2023, MyCompany")]
```

**44. Assembly Linker Options-Level Attributes**

```csharp
[assembly: AssemblyLinkers]

```
