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 667119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:53:36+00:00 2026-05-13T23:53:36+00:00

Sorry guys! i am so into the code! that i forgot to put the

  • 0

Sorry guys! i am so into the code! that i forgot to put the compiler errors.

Here is a new version of the code simplified!

And this are the errors:

Error 1 The best overloaded method match for ‘IWeird.DataBase.ModifyData(ref IWeird.IDataTable)’ has some invalid arguments
Error 2 Argument ‘1’: cannot convert from ‘ref IWeird.Periods’ to ‘ref IWeird.IDataTable’

The problem:
I can’t pass by reference an interface with a struct in it,
what am I doing wrong?

Here is the new example code:

class PeriodsProcessor
    {
        public PeriodsProcessor()
        {
            Periods Data = new Periods();
            DataBase DB = new DataBase();

            Console.WriteLine(Data.Value);
            DB.ModifyData(ref Data);
            Console.WriteLine(Data.Value);

            Console.ReadLine();
        }
    }


    public interface IDataTable
    {
        string Value { get; set; }
    }

    public struct Periods : IDataTable
    {
        public string Value { get; set; }
    }

    public class DataBase
    {
        public void ModifyData(ref IDataTable data) 
        {
            data.Value = "CHANGE";
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            PeriodsProcessor PeriodsProcessor = new PeriodsProcessor();
        }
    }
  • 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-13T23:53:36+00:00Added an answer on May 13, 2026 at 11:53 pm

    The problem is in DB.ModifyData<Period>(Data); method call. Your Data field is a struct, structs are passed to any methods by value which means that each time you call a method copy of the struct is created and is passed to the method. So actually your ModifyData method is modifying a copy of the Periods structure that is thrown away just after the method call.

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

Sidebar

Related Questions

Edit: Sorry guys, but I wasn't seeing this behavior when I came into work
Sorry guys, didn't know how to word this one. Still learning jquery and have
Sorry guys, not being lazy, I know others have had the same error message
Sorry guys, I posted this earlier today where my add as linked images were
Sorry for the wall of text guys but this one requires expliaining, way too
Ok guys, I'm really new at python (and programming itself) so sorry for my
Sorry guys, I'm a noob. I know that some languages support type casting, but
Sorry for big chunk of code, I couldn't explain that with less.Basically I'm trying
I've just started to get into using ViewModels. Can you guys check out this
Sorry, guys.I am quite new in mysql but I do need help from getting

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.