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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:53:09+00:00 2026-05-23T12:53:09+00:00

I am converting a Delphi code to a C#. I have a complex classes

  • 0

I am converting a Delphi code to a C#.

I have a complex classes structure where a class is the main ‘trunk’ of all its children.

In Delphi I can define the private/protected field with a type and the property for that field with the same type, and not write the type in child classes anymore.

Here is a bit (and functional) example:

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  Parent = class
  strict protected
    _myFirstField: Int64;
  public
    property MyFirstField: Int64    write _myFirstField;
  end;

  Child1 = class(Parent)
  public
    // Inherits the write/set behaviour..
    // And it doesn't need to define the type 'over and over' on all child classes.
    //
    // ******* Note MyFirstField here has not type.... ************
    property MyFirstField        read _myFirstField;  // Adding READ behaviour to the property.
  end;

var
  Child1Instance: Child1;
begin
    Child1Instance := Child1.Create;
    //Child1Instance.MyFirstField := 'An String';  <<-- Compilation error because type
    Child1Instance.MyFirstField := 11111;
    WriteLn(IntToStr(Child1Instance.MyFirstField));
    ReadLn;
end.

As you can see I don’t need to define the property type over and over.
If I need to change the var type in the future, I can change only in the parent class.

Is there any way to get this same behaviour in C#?

  • 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-23T12:53:09+00:00Added an answer on May 23, 2026 at 12:53 pm

    No, there ist. The types on the public API must be explicit. The only time you aren’t explicit is with var, which is limited to method variables.

    Further, you can’t change the signature in C# (adding a public getter in the subclass) – you would have to re-declare it:

    // base type 
    protected string Foo {get;set;}
    
    // derived type
    new public string Foo {
        get { return base.Foo; }
        protected set { base.Foo = value; }
    }
    

    But as the new suggests: this is an unrelated property and is not required to have the same type.

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

Sidebar

Related Questions

I have a C++ class that I am converting to Delphi that has a
I'm converting some C code to Delphi. Can someone please explain to me what
Converting my current code project to TDD, I've noticed something. class Foo { public
I'm converting the following example code to Delphi: http://msdn.microsoft.com/en-us/library/bb176406%28v=office.12%29.aspx My code is something like:
I'm converting GraphicEx project to Delphi 2009. I have trouble in converting following procedure
I am doing a project converting some Pascal (Delphi) code to C++ and would
I'm slowly converting my existing code into Delphi 2010 and read several of the
I'm making an application in C#, based on Delphi (converting code), but I found
I'm converting some legacy code to Delphi 2010. There are a fair number of
I'm converting my applications to Delphi 2009 and faced an intriguing issue with some

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.