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

  • SEARCH
  • Home
  • 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 6604723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:11:41+00:00 2026-05-25T19:11:41+00:00

I am fairly new to C#, and I come from a C++ background. I

  • 0

I am fairly new to C#, and I come from a C++ background.

I have defined a struct, and the (Microsoft) compiler keeps popping up the error CA1815 “‘GenericSendRequest’ should override Equals”

I read a bit around and saw that C# structs derive from ValueType which impleents a generic Equals using reflection. This confused me more:

  1. Why does the compiler create an error instead of a warning if its just a performance issue?
  2. Why does it define that generic Equals in the first place if it’s not going to let you use it?

So how can I tell the compiler that “I don’t care”? Something similar with just declaring assignment operator in a C++ class without providing definition to acknowledge that I know what I am doing.

So far my solution has been to include:

    public static bool operator ==(GenericSendRequest lhs, GenericSendRequest rhs)
    {
        return lhs.Equals(rhs);
    }

    public static bool operator !=(GenericSendRequest lhs, GenericSendRequest rhs)
    {
        return !lhs.Equals(rhs);
    }

    public override bool Equals(object obj)
    {
        return base.Equals(obj);
    }

    //Yes, it also makes me override GetHashCode since I'm overriding Equals.
    public override int GetHashCode()
    {
        return base.GetHashCode();
    }

in my struct, which is just awful.

Edit:
This is the struct definition:

public struct GenericSendRequest
{
        public LiveUser             Sender;
        public LiveUser[]           Receivers;
        public Message              Msg;
        public ServiceHttpRequest   HttpRequest;
}

Its usage is just multiple return values from a function:

public static GenericSendRequest CreateGenericSendRequest(...);
  • 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-25T19:11:42+00:00Added an answer on May 25, 2026 at 7:11 pm

    This is definitely not an error, its only a warning – and that warning even only will show up if you have enabled code analysis as part of your build. It’s a suggestion for performance optimization – take it that way.

    Edit:

    Turns out this is configurable:

    Go to Project Properties | Code Analysis | Run this rule set.. Open

    Expand the Performance section – for CA 1815 you can select whether you want this to be a warning, an error or none.

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to WPF and come from a WinForms background and have a fairly
I'm fairly new to C# and I come from a Ruby background. I still
I am fairly new to java having come from a VS2010 background. Currently working
I come from a networking background and I'm fairly new to web development but
I'm fairly new to nHibernate having come from an EF background and I'm struggling
I am fairly new with PDO but i have come across something which probably
I come from Linux and Windows programming is fairly new to me. On linux,
I am fairly new to coding in php and have come accross a bit
I'm fairly new to LWJGL/OpenGL and I've come across this problem which I can't
I am new to fairly new to AS3 and I have found myself needing

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.