Concorde
Concorde

Reputation: 61

I am a newbie creating an API using C#, encountered error "Severity Code Description Project File Line Suppression State Warning CS0108"

I am encountering this same error on the following fields:

public string txnumber { get; set; }
public string qnumber { get; set; }
public string accountnumber { get; set; }
public decimal amount { get; set; }
public string emailaddress { get; set; }

this is defined in the class Txn.cs.

The error text for all the variables is:

Severity Code Description Project File Line Suppression State Warning CS0108 'ReadTxn.txnumber' hides inherited member 'Txn.txnumber'. Use the new keyword if hiding was intended. QAny Severity Code Description Project File Line Suppression State Warning CS0108 'ReadTxn.txnumber' hides inherited member 'Txn.txnumber'. Use the new keyword if hiding was intended. QAny C:\Users\user\source\repos\QAny\QAny\Models\Txn.cs 37

Active Warning CS0108 'ReadTxn.qnumber' hides inherited member 'Txn.qnumber'. Use the new keyword if hiding was intended. QAny C:\Users\user\source\repos\QAny\QAny\Models\Txn.cs 38

Active Warning CS0108 'ReadTxn.accountnumber' hides inherited member 'Txn.accountnumber'. Use the new keyword if hiding was intended. QAny C:\Users\user\source\repos\QAny\QAny\Models\Txn.cs 39

Active Warning CS0108 'ReadTxn.amount' hides inherited member 'Txn.amount'. Use the new keyword if hiding was intended. QAny C:\Users\user\source\repos\QAny\QAny\Models\Txn.cs 40

Active Warning CS0108 'ReadTxn.emailaddress' hides inherited member 'Txn.emailaddress'. Use the new keyword if hiding was intended. QAny C:\Users\user\source\repos\QAny\QAny\Models\Txn.cs 41

======== here is the Txn.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace QAny.Models
{
    public class Txn
    {
        // define all the proeperties of the table with get and set
        public string txnumber { get; set; }
        public string qnumber { get; set; }
        public string accountnumber { get; set; }
        public decimal amount { get; set; }
        public string emailaddress { get; set; }

    }

    // will create a class to create an object of txn class

    public class createTxn : Txn
    {

    }

    public class ReadTxn : Txn
    {
        public ReadTxn(System.Data.DataRow row)
        {
            txnumber = row["txnumber"].ToString();
            qnumber = row["qnumber"].ToString();
            accountnumber = row["accountnumber"].ToString();
            amount = Convert.ToDecimal(row["amount"]);
            emailaddress = row["emailaddress"].ToString();
        }

        public string txnumber { get; set; }
        public string qnumber { get; set; }
        public string accountnumber { get; set; }
        public decimal amount { get; set; }
        public string emailaddress { get; set; }

    }
}

Upvotes: 0

Views: 491

Answers (1)

Kacper
Kacper

Reputation: 598

Messages you are seeing indicate that class ReadTxn derives from class Txn which already contains members with the same names.

Those are not errors, just warnings. If you want to suppress them just add new keyword to your property declaration, but remember this also probably means you're doing something wrong because hiding members of a base class is rarely something you actually want to do. To understand this concept better you should read about inheritance in c#. Microsoft docs can be good place to start.

Upvotes: 1

Related Questions