Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello experts

I would need to create a partial class for System.Exception

C#
namespace System
{
    public partial class Exception
    {
        public void Something()
        {
            //...
        }
    }
}


unfortunately, it does not accept that as a partial of the real System.Exception

I do not plan to create an extended method.

Do you think there is a way to create a partial class?


Thank you
Posted
Comments
Jameel VM 11-Jun-15 18:44pm    
why are creating partial classes? extend the class and make custom exception
PIEBALDconsult 11-Jun-15 18:45pm    
No; just derive a custom Exception.
[no name] 12-Jun-15 1:05am    
Have you read the documentation? https://msdn.microsoft.com/en-us/library/wa80x488.aspx
mariazingzing 12-Jun-15 3:23am    
No what is it about?
[no name] 12-Jun-15 4:07am    
I guess that's the point of reading it.

1 solution

C#
//**1
namespace System
{
   //This is not a partial class
    public class Exception : ISerializable, _Exception
    {
    }
}
1.you can not create a partial class of Exception becoz Exception is not a partial   

2.Your Exception class  means your_projectname.System.Exception which is not     equals to System.Exception 

3.All partial-type definitions meant to be parts of the same type must be defined in the same assembly and the same module (.exe or .dll file). Partial definitions cannot span multiple modules.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900