473,414 Members | 1,677 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,414 software developers and data experts.

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 1837
Say i have:
>
[Serializable]
public class A
{

}

public class B : A
{
}

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

But SerializableAttribute has Inherited=false attribute and cannot be
inherited:

[ComVisible(true), AttributeUsage(AttributeTargets.Delegate |
AttributeTargets.Enum | AttributeTargets.Struct |
AttributeTargets.Class, Inherited=false)]
public sealed class SerializableAttribute : 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.public.dotnet.languages.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...@bigfoot.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
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...
3
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
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: ...
9
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...
4
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...
3
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...
2
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,...
1
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
by: Lee | last post by:
public class ClassA { private string _FieldName; public string FieldName { get { return _FieldName; } } }
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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: 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...

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.