473,399 Members | 3,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Re static in attributes

Actually I am not understanding what you mean by
attribute will not be applicable to the type, but rather, all types
you mean it will behave like
[AttributeUsage(AttributeTargets.All)]

??

Thanks,
Po

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@tk2msftngp13.phx.gbl... Pohihihi,

Attributes can have static methods/properties, just like any other
class. However, you have to remember that a static method/property on an
attribute will not be applicable to the type, but rather, all types.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ca*******@caspershouse.com

"Pohihihi" <po******@hotmail.com> wrote in message
news:u4****************@TK2MSFTNGP12.phx.gbl...
In what condition attributes (class) might have static methods?



Nov 17 '05 #1
2 1442
Pohihihi,

No, what I meant was that instance properties and methods on an
attribute have the scope of the thing they are applied to (let's assume we
are talking about a class here for a moment).

With static members, those are applicable to everything. Remember, an
attribute is applied to a type, or part of a type, and becomes part of the
metadata for that type. If you are going to add static members to an
attribute, make sure it is designed properly.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Pohihihi" <po******@hotmail.com> wrote in message
news:ey**************@tk2msftngp13.phx.gbl...
Actually I am not understanding what you mean by
attribute will not be applicable to the type, but rather, all types


you mean it will behave like
[AttributeUsage(AttributeTargets.All)]

??

Thanks,
Po

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:%2****************@tk2msftngp13.phx.gbl...
Pohihihi,

Attributes can have static methods/properties, just like any other
class. However, you have to remember that a static method/property on an
attribute will not be applicable to the type, but rather, all types.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ca*******@caspershouse.com

"Pohihihi" <po******@hotmail.com> wrote in message
news:u4****************@TK2MSFTNGP12.phx.gbl...
In what condition attributes (class) might have static methods?


Nov 17 '05 #2
Thanks for the reply Nicholas but I guess I am still not getting what you
mean. I understand that attrib do things like class and having static
methods will behave like a class static but what is the use and how it is
applied is still a question for me. Are there any links that I might go
throw to understand the deep concepts?

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:uD*************@tk2msftngp13.phx.gbl...
Pohihihi,

No, what I meant was that instance properties and methods on an
attribute have the scope of the thing they are applied to (let's assume we
are talking about a class here for a moment).

With static members, those are applicable to everything. Remember, an
attribute is applied to a type, or part of a type, and becomes part of the
metadata for that type. If you are going to add static members to an
attribute, make sure it is designed properly.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Pohihihi" <po******@hotmail.com> wrote in message
news:ey**************@tk2msftngp13.phx.gbl...
Actually I am not understanding what you mean by
attribute will not be applicable to the type, but rather, all types


you mean it will behave like
[AttributeUsage(AttributeTargets.All)]

??

Thanks,
Po

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:%2****************@tk2msftngp13.phx.gbl...
Pohihihi,

Attributes can have static methods/properties, just like any other
class. However, you have to remember that a static method/property on
an
attribute will not be applicable to the type, but rather, all types.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ca*******@caspershouse.com

"Pohihihi" <po******@hotmail.com> wrote in message
news:u4****************@TK2MSFTNGP12.phx.gbl...
In what condition attributes (class) might have static methods?


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Daniel Schüle | last post by:
Hi all I have 2 questions 1) is there a way do declare static variables in a class? I coded this logic in global variable foo_cnt 2) is there a way to see the types of all data/function...
33
by: Chris Capel | last post by:
What is the rationale behind the decision not to allow abstract static class members? It doesn't seem like it's a logically contradictory concept, or that the implementation would be difficult or...
19
by: Mike Ruane-Torr | last post by:
Why can't I have a static abstract method in C#? My intention is to have a class-level method that returns a string to supply information about inherited classes, and it is natural to make this...
5
by: Ren? Paw Christensen | last post by:
Hi. Considering the following code, I want this call: Something.Method(); To return "Something". public class BaseClass { public static string Method() {
10
by: Michael Yanowitz | last post by:
Is it possible to have a static variable in Python - a local variable in a function that retains its value. For example, suppose I have: def set_bit (bit_index, bit_value): static bits = ...
3
by: dmitrey | last post by:
Thank you in advance, Dmitrey
0
by: xieml2007 | last post by:
Dear Madam or Sir, I encountered one problem which is quite similiar to the discussions launched at the web site: http://www.thescripts.com/forum/thread280324.html
2
by: MichaelD | last post by:
Just read a book on OOPHP and started playing around with PHP's OOP. Most of it's working just fine, but I cant seem to figure out how to access static attributes - here's my code: class testing...
0
by: Luis Zarrabeitia | last post by:
Quoting Joe Strout <joe@strout.net>: I'm sure your credentials are bigger than mine. But he is right. A lot of languages have ditched the "concept" of a static variable on a method (how do you...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.