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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:04:07+00:00 2026-05-26T05:04:07+00:00

I have a Patient class: class Patient { public string First_Name { get; set;

  • 0

I have a Patient class:

class Patient {
  public string First_Name { get; set; }
  public string Last_Name { get; set; }
  public DateTime Date_of_Birth { get; set; }
}

I also have an interface:

interface IPerson {
  string First_Name { get; }
  string Last_Name { get; }
}

in this console application, I would like the Display_Person method to work. It compiles but throws a run time error because Patient does not implement IPerson.

class Program {
  static void Main(string[] args) {
    Patient p = new Patient { 
      First_Name = "Charles", Last_Name = "Lambert",
      Date_of_Birth = new DateTime(1976,5,12),
    };
    Display_Person(p);
  }

  static void Display_Person(dynamic person) {
    IPerson p = person;
    Console.WriteLine("{0}, {1}", p.Last_Name, p.First_Name);
  }
}

What code changes, without having Patient implement the IPerson interface, can I make to get the Display_Person method to work? I would prefer a solution that is reusable.

Update: I want this to work so I can get intellisense. Please look past the triviality of this example. It short and to the point at explaining my problem. If this were 1003 loan application (when printed is the size of a book), I would not want to apply 20+ interfaces to my class so I can group related data for calculations. I also would not like having to type out all of those properties every time. The lack of intellisense has steered me away from using dynamic languages in the past. (I’m not lazy i’m efficient!)

  • 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-26T05:04:08+00:00Added an answer on May 26, 2026 at 5:04 am

    You can use Impromptu Interface to do that.

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

Sidebar

Related Questions

Well i have a complex form view model like this : public class TransactionFormViewModel
I have a class which is mirror of table. public class Patient { public
Suppose I have a method public Patient(int id) { ---- } that returns Patient
Having this schema : Doctor(license_no, doctor_name, specialty) Patient(pat_id, pat_name, pat_address, pat_phone, date_of_birth) Visit(license_no, pat_id,
I have a validation interface like so: public interface IValidation<T> { bool IsValid(T item,
I have a Patient entity and a List entity. A Patient can belong to
I have two entities: Patient and Job. Patient has a to-many relationship to Job
I have a database with the following table: PATIENT (PATIENT_ID*, MEDICAL_EXAMINATIONS) where the field
I have this very simple sql statement: SELECT max_dose FROM psychotropes WHERE (patient_meds.psychotrope =
In my Core Data model I have two entities: List and Patient. List has

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.