I need to override the body of Tostring method , and check something during using this method and it should be an extension method, but I should do it in a seprated DLL file and use the method in another project.Developers should not understand the Tostring
method is not a real one and it is an overrided method so please let me know what to do exactly to have such a method.
It is correct and it is so easy ,but I need to put the method in seprated DLL and because I want to make an extension method , the class should be Static then I can not override anything in Static class and it is my problem.
Thanks , but It is correct and so easy ,but I need to put the method in seprated DLL and because I want to make an extension method , the class should be Static then I can not override anything in Static class and it is my problem.
"You can use extension methods to extend a class or interface,
but not to override them.
An extension method with the same name and signature as an interface or class method will
never be called.
alikolahdoozan
Developers should not understand the Tostring method is not a real one and it is an overrided method
why? what are you trying to hide?
N.B.: op. cit.
"Extension methods are only in scope when you explicitly import the namespace into your source code with a using directive."
g.
B-) Please help me by completing my school survey about computer programmers on my website. Thank you!!! Gerry Lowry +1 705-429-7550 wasaga beach, ontario, canada
Developers should not understand the Tostring method is not a real one and it is an overrided method.
I need to change the body of the method and hide something related to security of my company and not to show them.Now I understand it is impossible so I have changed my idea and handle the issue by another way to solve.
Ahhh ... one of my all time favourites, security by obscurity. It brings back such fond memories. I remember using a mainframe system where the powers that be decided that they wanted to stop 'the wrong people' from using a system. Answer? Remove the
help files. The idea was that the system was so difficult to use that without Help people who had not been trained could not use the system. Pure brilliance!
When you should employe 100 staff , you can not stick them to the chair and ask them not to bring the source code out of the company .I keep my source code safe with put them in dark by partial classes and DLLs even someone is agree or not,I should keep
myself safe from some crazy staff and also another part of company on top of me. Kicking me out from the company is too hard for them with my coding style and they need me for ever. I know it is not so nice , but in 21th century with a lot of economical crises
you should take care of your position alot.
alikolahdooz...
Member
77 Points
65 Posts
Overriding Tostring Method.
May 21, 2012 03:56 AM|LINK
Hi
I need to override the body of Tostring method , and check something during using this method and it should be an extension method, but I should do it in a seprated DLL file and use the method in another project.Developers should not understand the Tostring method is not a real one and it is an overrided method so please let me know what to do exactly to have such a method.
Regards
Ali
tusharrs
Contributor
3230 Points
668 Posts
Re: Overriding Tostring Method.
May 21, 2012 04:29 AM|LINK
http://msdn.microsoft.com/en-us/library/ms173154(v=vs.80).aspx
( Mark as Answer if it helps you out )
View my Blog
alikolahdooz...
Member
77 Points
65 Posts
Re: Overriding Tostring Method.
May 21, 2012 04:33 AM|LINK
Dear tusharrs
It is correct and it is so easy ,but I need to put the method in seprated DLL and because I want to make an extension method , the class should be Static then I can not override anything in Static class and it is my problem.
Regards
Ali
brijeshvaidy...
Participant
848 Points
231 Posts
Re: Overriding Tostring Method.
May 21, 2012 04:34 AM|LINK
hi,
pls look below link,
it may help you.
http://msdn.microsoft.com/en-us/library/ms173154(v=vs.80).aspx
Brijesh Vaidya
India
alikolahdooz...
Member
77 Points
65 Posts
Re: Overriding Tostring Method.
May 21, 2012 04:37 AM|LINK
Thanks , but It is correct and so easy ,but I need to put the method in seprated DLL and because I want to make an extension method , the class should be Static then I can not override anything in Static class and it is my problem.
Regards
Ali
gerrylowry
All-Star
20513 Points
5712 Posts
Re: Overriding Tostring Method.
May 21, 2012 04:40 AM|LINK
@ alikolahdoozan
why?
http://msdn.microsoft.com/en-us/library/bb383977.aspx "Extension Methods (C# Programming Guide)"
"You can use extension methods to extend a class or interface,
but not to override them.
An extension method with the same name and signature as an interface or class method will never be called.
why? what are you trying to hide?
N.B.: op. cit.
"Extension methods are only in scope when you explicitly import the namespace into your source code with a using directive."
g.
alikolahdooz...
Member
77 Points
65 Posts
Re: Overriding Tostring Method.
May 21, 2012 04:57 AM|LINK
Developers should not understand the Tostring method is not a real one and it is an overrided method.
I need to change the body of the method and hide something related to security of my company and not to show them.Now I understand it is impossible so I have changed my idea and handle the issue by another way to solve.
Regards
Ali
Paul Linton
Star
13405 Points
2532 Posts
Re: Overriding Tostring Method.
May 21, 2012 06:03 AM|LINK
Ahhh ... one of my all time favourites, security by obscurity. It brings back such fond memories. I remember using a mainframe system where the powers that be decided that they wanted to stop 'the wrong people' from using a system. Answer? Remove the help files. The idea was that the system was so difficult to use that without Help people who had not been trained could not use the system. Pure brilliance!
alikolahdooz...
Member
77 Points
65 Posts
Re: Overriding Tostring Method.
May 21, 2012 09:04 AM|LINK
When you should employe 100 staff , you can not stick them to the chair and ask them not to bring the source code out of the company .I keep my source code safe with put them in dark by partial classes and DLLs even someone is agree or not,I should keep myself safe from some crazy staff and also another part of company on top of me. Kicking me out from the company is too hard for them with my coding style and they need me for ever. I know it is not so nice , but in 21th century with a lot of economical crises you should take care of your position alot.