简体   繁体   English

在Xamarin Forms中将属性从一个类访问到另一个类

[英]Access Properties from a class into another class in Xamarin Forms

I would like to access the email of this class into another class that I am already instantiated on my render page. 我想将此类的电子邮件访问到我已经在渲染页面上实例化的另一个类中。 Any help very much appreciated. 任何帮助,非常感谢。

public class Access
    {
        public string Email { get; set; } //I want this value...

    }  
public class Types
    {
        public string Id { get; set; }
        public string Sum { get; set; }
        public string Addition { get; set; }
        public string Email { get; set; } // ...to be this value inside my class TYPES
  }

Well I think you can simply use a copy constructor for the Types class with the Access instance as parameter from which you want to copy the email value when creating a new Types instance. 好吧,我认为您可以为Types类简单地使用一个复制构造函数,并将Access实例作为参数,在创建新的Types实例时要从中复制电子邮件值。

From what you said it seems you don't care if its a particular instance (as your post is a bit confusing between class and instance) 从您所说的内容来看,您似乎并不在乎它是否是一个特定的实例(因为您的帖子在类和实例之间有点混乱)

 public class Types
 {
  public string Id { get; set; }
  public string Sum { get; set; }
  public string Addition { get; set; }
  public string Email { get; set; }

  public Types(Access access)
    {
      Email = access.Email
    }
 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM