473,623 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

are attributes inherited

Say i have:

[Serializable]
public class A
{

}

public class B : A
{
}

does B need the serializable attribute as well?

dan
Apr 26 '07 #1
3 1849
Say i have:
>
[Serializable]
public class A
{

}

public class B : A
{
}

does B need the serializable attribute as well?
In this case yes. See "AttributeUsage Attribute.Inher ited".
Apr 26 '07 #2
Attributes are inherited.

But SerializableAtt ribute has Inherited=false attribute and cannot be
inherited:

[ComVisible(true ), AttributeUsage( AttributeTarget s.Delegate |
AttributeTarget s.Enum | AttributeTarget s.Struct |
AttributeTarget s.Class, Inherited=false )]
public sealed class SerializableAtt ribute : Attribute
{
...
}

So B needs this one also.

WBR, Alex Meleta
Blog: http://devkids.blogspot.com

-----Original Message-----
From: Dan Holmes [mailto:da****** *@bigfoot.com]
Posted At: Donnerstag, 26. April 2007 22:15
Posted To: microsoft.publi c.dotnet.langua ges.csharp
Conversation: are attributes inherited
Subject: are attributes inherited

Say i have:

[Serializable]
public class A
{

}

public class B : A
{
}

does B need the serializable attribute as well?

dan

Apr 26 '07 #3
On Apr 26, 2:15 pm, Dan Holmes <danhol...@bigf oot.comwrote:
Say i have:

[Serializable]
public class A
{

}

public class B : A
{

}

does B need the serializable attribute as well?

dan
Well, in this particular case yes, you do. However, the attribute
itself defines if it will be inherited, so you'll have to check the
documentation.

Apr 26 '07 #4

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

Similar topics

2
2473
by: Edward Diener | last post by:
If I set an attribute on some part of a class, such as a property or event, does that attribute also apply to the same property or event of a derived class ? If the above is true, can I change the attribute of a property or event from something in a base class to something different in a derived class ?
3
1321
by: Laurent | last post by:
I'm seaching how to be warned when hiding inherited attributes. Using GCC 3.3.x class Elephant : Animal { int attr1; }; class Animal { int attr1; };
5
1799
by: Garmt de Vries | last post by:
I have a table listing various translations of the titles of a set of books. Each row represents a book, each column represents a language. It looks like this: +-------------------+------------------+-------------------+ | Français | English | Deutsch | +-------------------+------------------+-------------------+ | Le tour du monde | Around the world | Die Reise um die | | en 80 jours | in 80 days ...
9
3587
by: Alex | last post by:
I have a serious problem and I hope there is some solution. It is easier to illustrate with a simple code: >>> class Parent(object): __slots__= def __init__(self, a, b): self.A=a; self.B=b def __getstate__(self): return self.A, self.B def __setstate__(self, tup):
4
2024
by: Mike Jansen | last post by:
Does anyone know why if I create a complexType based off another complexType using xsd:extension the attributes don't seem to be inherited? Is this a bug/non-implementation in the .NET Schema editor and the XML validator? Thanks, Mike Jansen
3
1629
by: Janaka | last post by:
I've seen and used some samples where you can set the onclick attrubute to a Button control to get it to do some javascript a la : btnUse.Attributes = "DoSomeJS()"; However when i try and get this to work on certain controls such as the ListItem in a RadioButtonList it just doesn't do anything? Does this attributes property only render for certain controls?
2
1344
by: Shawn Harrison | last post by:
Greetings, I'm using pg 7.3.5 and playing with table inheritance, and I've run into the fact that foreign keys cannot be defined on inherited attributes. (As much is stated in the documentation, but it didn't sink in until I ran into the fact.) The documents say this will probably be fixed in a future release. My question is, are there any definite plans in that direction at this point?
1
1387
by: guy | last post by:
simple question, are attributes inherited? eg if base class is marked serializable are classes that inherit from it also serializable?
1
1582
by: Lee | last post by:
public class ClassA { private string _FieldName; public string FieldName { get { return _FieldName; } } }
0
8227
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8670
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8613
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8469
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6106
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5561
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4074
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2602
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1473
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.