質問編集履歴

4

変更

2021/11/11 05:05

投稿

person
person

スコア223

test CHANGED
File without changes
test CHANGED
@@ -88,9 +88,9 @@
88
88
 
89
89
 
90
90
 
91
- Person.print_info();
91
+ person1.print_info();
92
-
92
+
93
- Person.print_info();
93
+ person2.print_info();
94
94
 
95
95
 
96
96
 
@@ -192,7 +192,7 @@
192
192
 
193
193
  /// <returns></returns>
194
194
 
195
- public static void print_info()
195
+ public void print_info()
196
196
 
197
197
  {
198
198
 
@@ -213,85 +213,3 @@
213
213
  エラー
214
214
 
215
215
  ![イメージ説明](f09734a886ca3ee095c204a988da6b8a.png)
216
-
217
-
218
-
219
- 変更後のエラー
220
-
221
- ![イメージ説明](4414ac3172ed1b48ed2720be4d1da296.png)
222
-
223
-
224
-
225
- エラーの対処。
226
-
227
- > 現在のコンテキストに'person1'という名前は存在しません。
228
-
229
- > 現在のコンテキストに'person2'という名前は存在しません。
230
-
231
- > 変数'person'は宣言されていますが、使用されていません。
232
-
233
- ```C#
234
-
235
- // Program.cs
236
-
237
-
238
-
239
- // Person person;
240
-
241
- Person person1, person2; // 変数の定義ミス修正
242
-
243
- ```
244
-
245
-
246
-
247
- > 'Person.Person(string, int)'はアクセスできない保護レベルになっています。
248
-
249
- ```C#
250
-
251
- // Person.cs
252
-
253
-
254
-
255
- //string name = "";
256
-
257
- //int age = 0;
258
-
259
-
260
-
261
- public string name = ""; // publicをつけることで、privateからpublicへ変更
262
-
263
- public int age = 0;
264
-
265
- ```
266
-
267
-
268
-
269
- その他修正
270
-
271
- > インスタンス参照でメンバー'Person.print_info()'にアクセスできません。代わりに型名を使用してください。
272
-
273
-
274
-
275
- これについては、エラー修正を進める上で表示されたから変更したが、
276
-
277
- Pythonのselfとはちょっと仕組みが違う?同じようには使えない?
278
-
279
-
280
-
281
- ```C#
282
-
283
- // Program.cs
284
-
285
-
286
-
287
- //person1.print_info();
288
-
289
- //person2.print_info();
290
-
291
-
292
-
293
- Person.print_info();
294
-
295
- Person.print_info();
296
-
297
- ```

3

修正

2021/11/11 05:04

投稿

person
person

スコア223

test CHANGED
File without changes
test CHANGED
@@ -263,3 +263,35 @@
263
263
  public int age = 0;
264
264
 
265
265
  ```
266
+
267
+
268
+
269
+ その他修正
270
+
271
+ > インスタンス参照でメンバー'Person.print_info()'にアクセスできません。代わりに型名を使用してください。
272
+
273
+
274
+
275
+ これについては、エラー修正を進める上で表示されたから変更したが、
276
+
277
+ Pythonのselfとはちょっと仕組みが違う?同じようには使えない?
278
+
279
+
280
+
281
+ ```C#
282
+
283
+ // Program.cs
284
+
285
+
286
+
287
+ //person1.print_info();
288
+
289
+ //person2.print_info();
290
+
291
+
292
+
293
+ Person.print_info();
294
+
295
+ Person.print_info();
296
+
297
+ ```

2

変更

2021/11/11 04:53

投稿

person
person

スコア223

test CHANGED
File without changes
test CHANGED
@@ -42,7 +42,7 @@
42
42
 
43
43
 
44
44
 
45
- Program.cs
45
+ Program.cs(変更しました。)
46
46
 
47
47
  ```C#
48
48
 
@@ -76,7 +76,7 @@
76
76
 
77
77
  // インスタンス格納用変数定義
78
78
 
79
- Person person;
79
+ Person person1, person2;
80
80
 
81
81
 
82
82
 
@@ -88,9 +88,9 @@
88
88
 
89
89
 
90
90
 
91
- person1.print_info();
91
+ Person.print_info();
92
-
92
+
93
- person2.print_info();
93
+ Person.print_info();
94
94
 
95
95
 
96
96
 
@@ -140,7 +140,7 @@
140
140
 
141
141
 
142
142
 
143
- Person.cs
143
+ Person.cs(変更しました。)
144
144
 
145
145
  ```C#
146
146
 
@@ -148,13 +148,13 @@
148
148
 
149
149
 
150
150
 
151
- class Person
151
+ public class Person
152
152
 
153
153
  {
154
154
 
155
- string name = "";
155
+ public string name = "";
156
-
156
+
157
- int age = 0;
157
+ public int age = 0;
158
158
 
159
159
 
160
160
 
@@ -168,7 +168,7 @@
168
168
 
169
169
  /// <returns></returns>
170
170
 
171
- Person(String name, int age)
171
+ public Person(String name, int age)
172
172
 
173
173
  {
174
174
 
@@ -213,3 +213,53 @@
213
213
  エラー
214
214
 
215
215
  ![イメージ説明](f09734a886ca3ee095c204a988da6b8a.png)
216
+
217
+
218
+
219
+ 変更後のエラー
220
+
221
+ ![イメージ説明](4414ac3172ed1b48ed2720be4d1da296.png)
222
+
223
+
224
+
225
+ エラーの対処。
226
+
227
+ > 現在のコンテキストに'person1'という名前は存在しません。
228
+
229
+ > 現在のコンテキストに'person2'という名前は存在しません。
230
+
231
+ > 変数'person'は宣言されていますが、使用されていません。
232
+
233
+ ```C#
234
+
235
+ // Program.cs
236
+
237
+
238
+
239
+ // Person person;
240
+
241
+ Person person1, person2; // 変数の定義ミス修正
242
+
243
+ ```
244
+
245
+
246
+
247
+ > 'Person.Person(string, int)'はアクセスできない保護レベルになっています。
248
+
249
+ ```C#
250
+
251
+ // Person.cs
252
+
253
+
254
+
255
+ //string name = "";
256
+
257
+ //int age = 0;
258
+
259
+
260
+
261
+ public string name = ""; // publicをつけることで、privateからpublicへ変更
262
+
263
+ public int age = 0;
264
+
265
+ ```

1

修正

2021/11/11 04:44

投稿

person
person

スコア223

test CHANGED
File without changes
test CHANGED
@@ -28,15 +28,15 @@
28
28
 
29
29
   ├ ConsoleApp1\
30
30
 
31
-    ├ bin\
31
+  ...├ bin\
32
-
32
+
33
-    ├ obj\
33
+  ...├ obj\
34
-
34
+
35
-    ├ ConsoleApp1.csproj
35
+  ...├ ConsoleApp1.csproj
36
-
36
+
37
-    ├ Person.cs
37
+  ...├ Person.cs
38
-
38
+
39
-    └ Program.cs
39
+  ...└ Program.cs
40
40
 
41
41
   └ ConsoleApp1.sh
42
42