当前位置:网站首页>Can I use read-only to automatically implement properties- Is read-only auto-implemented property possible?
Can I use read-only to automatically implement properties- Is read-only auto-implemented property possible?
2022-07-03 02:52:00 【Technology feast】
problem :
I found a topic on MSDN that talks that yes, this is possible. I am here MSDN Found a topic on , Yes , It's possible .
I did a test that seems to break this statement: I did a test that seemed to break this statement :
using System;namespace Test{ class Program { static void Main(string[] args) { Foo f = new Foo("1"); Console.WriteLine(f.Bar); // prints 1 f.Test("2"); Console.WriteLine(f.Bar);// successfully prints 2 } } class Foo { public Foo(string b) { this.Bar = b; } public string Bar { get; private set; } public void Test(string b) { // this would be impossible for readonly field! // next error would be occur: CS0191 or CS0191 // A readonly field cannot be assigned to (except in a constructor or a variable initializer) this.Bar = b; } }}
Where am I wrong? What's wrong with me ?
Solution :
Reference resources : https://stackoom.com/en/question/API7边栏推荐
- [flutter] example of asynchronous programming code between future and futurebuilder (futurebuilder constructor setting | handling flutter Chinese garbled | complete code example)
- Practice of traffic recording and playback in vivo
- The left value and the right finger explain better
- sql server 查詢指定錶的錶結構
- Mathematical statistics -- Sampling and sampling distribution
- The Linux server needs to install the agent software EPS (agent) database
- 迅雷chrome扩展插件造成服务器返回的数据js解析页面数据异常
- MATLAB小技巧(24)RBF,GRNN,PNN-神经网络
- Reset or clear NET MemoryStream - Reset or Clear . NET MemoryStream
- Wechat - developed by wechat official account Net core access
猜你喜欢
用docker 連接mysql的過程
Summary of interview project technology stack
基于can总线的A2L文件解析(2)
迅雷chrome扩展插件造成服务器返回的数据js解析页面数据异常
Your family must be very poor if you fight like this!
Add automatic model generation function to hade
I2C 子系统(三):I2C Driver
Three.js本地环境搭建
Error invalid bound statement (not found): com ruoyi. stock. mapper. StockDetailMapper. XXXX solution
Check log4j problems using stain analysis
随机推荐
一文带你了解 ZigBee
SQL statement
Random Shuffle attention
【翻译】具有集中控制平面的现代应用负载平衡
I2C 子系統(四):I2C debug
Unity3d human skin real time rendering real simulated human skin real time rendering "suggestions collection"
Your family must be very poor if you fight like this!
Basic operation of binary tree (C language version)
Mathematical statistics -- Sampling and sampling distribution
Deep learning: multi-layer perceptron and XOR problem (pytoch Implementation)
Three.js本地环境搭建
【翻译】后台项目加入了CNCF孵化器
左值右指解释的比较好的
力扣------网格中的最小路径代价
Three. JS local environment setup
定了,就选它
左连接,内连接
HW initial preparation
MATLAB小技巧(24)RBF,GRNN,PNN-神经网络
sql server 查询指定表的表结构