简体   繁体   English

Bindings中的属性名称不区分大小写?

[英]Property name in Bindings case insensitive?

I was debugging a piece of code and to my surprise the following lines both worked correct. 我正在调试一段代码,令我惊讶的是以下几行都正常。

Binding binding = new Binding("Text", myObject, "PropertyName");

Binding binding = new Binding("Text", myObject, "propertyname");

It seems that the property name is case-insensitive, but I cannot find anything about this. 似乎属性名称不区分大小写,但我找不到任何关于此的内容。

Can anybody tell me if I am missing something, or what could be the rational behind this? 任何人都可以告诉我,如果我错过了什么,或者这背后的理性是什么?

I don't know where it is documented, but it is in the source indeed. 我不知道它在哪里记录,但它确实在源头

It uses a StringComparison.OrdinalIgnoreCase to compare the property name from the binding with the actual object's property: 它使用StringComparison.OrdinalIgnoreCase将绑定的属性名称与实际对象的属性进行比较:

if( tempPropInfo==null
    &&
    String.Equals (propInfos[i].Name, propertyName, StringComparison.OrdinalIgnoreCase)
  )
  {
  }

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

相关问题 Entity Framework 7 中表和属性的不区分大小写的名称 - Case insensitive name of tables and properties in Entity Framework 7 C#Expression String.IndexOf不区分大小写,属性选择器 - C# Expression String.IndexOf case insensitive with the property selector .NET Core中不使用JsonProperty的不区分大小写的属性绑定 - Case-Insensitive Property Binding Without Using JsonProperty in .NET Core Json.NET不区分大小写的属性反序列化 - Json.NET Case-insensitive Property Deserialization 使用 WinSCP 和 C# 匹配不区分大小写的文件夹名称 - Case insensitive folder name matching using WinSCP and C# MongoDB:不区分大小写和变音 - MongoDB: Case insensitive and accent insensitive 当我使用区分大小写的语言时,如何解决COM中不区分大小写的冲突名称 - How to solve case insensitive conflict name in COM while I using a case sensitive language JsonSerializerSettings更改属性名称的大小写,但不更改属性名称 - JsonSerializerSettings to change case of property name but not name of property's property C#Winforms-具有相同属性名称的数据绑定用于不同的控件 - C# Winforms - Data Bindings with Same Property Name for Different Controls LINQ不区分大小写 - LINQ case insensitive
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM