Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6361361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:46:04+00:00 2026-05-24T23:46:04+00:00

I may not have it correct, but I saw something like this above a

  • 0

I may not have it correct, but I saw something like this above a WebMethod:

[return:(XmlElement("Class2"),IsNullable = false)]
public Class2 MEthod1()
{

}

I saw a vb version first and I used a converter to convert it to c#. I have never seen it before. It’s in a vb 6 asmx file.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:46:05+00:00Added an answer on May 24, 2026 at 11:46 pm

    It’s an attribute target, and it’s being used in your example to disambiguate usage on the return value from other elements:

    // default: applies to method
    [SomeAttr]
    int Method1() { return 0; } 
    
    // applies to method
    [method: SomeAttr]
    int Method2() { return 0; } 
    
    // applies to return value
    [return: SomeAttr]
    int Method3() { return 0; } 
    

    When creating attributes you can specify which language elements an attribute can be applied to. This is illustrated in the example below.

    For a list of available targets see here:
    http://msdn.microsoft.com/en-us/library/system.attributetargets.aspx

    namespace AttTargsCS 
    {
        // This attribute is only valid on a class.
        [AttributeUsage(AttributeTargets.Class)]
        public class ClassTargetAttribute : Attribute {
        }
    
        // This attribute is only valid on a method.
        [AttributeUsage(AttributeTargets.Method)]
        public class MethodTargetAttribute : Attribute {
        }
    
        // This attribute is only valid on a constructor.
        [AttributeUsage(AttributeTargets.Constructor)]
        public class ConstructorTargetAttribute : Attribute {
        }
    
        // This attribute is only valid on a field.
        [AttributeUsage(AttributeTargets.Field)]
        public class FieldTargetAttribute : Attribute {
        }
    
        // This attribute is valid on a class or a method.
        [AttributeUsage(AttributeTargets.Class|AttributeTargets.Method)]
        public class ClassMethodTargetAttribute : Attribute {
        }
    
        // This attribute is valid on any target.
        [AttributeUsage(AttributeTargets.All)]
        public class AllTargetsAttribute : Attribute {
        }
    
        [ClassTarget]
        [ClassMethodTarget]
        [AllTargets]
        public class TestClassAttribute {
            [ConstructorTarget]
            [AllTargets]
            TestClassAttribute() {
            }
    
            [MethodTarget]
            [ClassMethodTarget]
            [AllTargets]
            public void Method1() {
            }
    
            [FieldTarget]
            [AllTargets]
            public int myInt;
    
            static void Main(string[] args) {
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It is quite possible that I may not have got the point, but I
I have a segmentated image, looks like this: // I am not allowed to
Update: This may not be Pairing. This may just need to have a service
I have a datagridview that may or may not have rows selected when the
I have a User class which may or may not have an associated Department.
I have a byte array that may or may not have null bytes at
My situation: ClassA may or may not have a parent of type ClassB .
I have a bunch of models that may or may not have a property
On my app a user may or may not have a profile. An example
I have a list/collection of objects that may or may not have the same

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.