teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

4

追記

2018/02/17 11:55

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -110,4 +110,9 @@
110
110
  ```
111
111
  ```
112
112
  error CS1061: Type `Test' does not contain a definition for `s' and no extension method `s' of type `Test' could be found. Are you missing an assembly reference?
113
+ ```
114
+ ちなみに下記は通ります。
115
+ ```
116
+ string ss = new Test ("1").s;
117
+ Debug.Log (ss); //1
113
118
  ```

3

追記②

2018/02/17 11:55

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -67,4 +67,47 @@
67
67
  ```
68
68
  ```
69
69
  Assets/Sample.cs(33,53): error CS1061: Type `T' does not contain a definition for `s' and no extension method `s' of type `T' could be found. Are you missing an assembly reference?
70
+ ```
71
+
72
+ ###追記②
73
+ ```
74
+ using System.Collections;
75
+ using System.Collections.Generic;
76
+ using UnityEngine;
77
+ using System.Linq;
78
+
79
+ class Test{
80
+
81
+ public string s ="";
82
+
83
+ public Test(string b){
84
+ s = b;
85
+ }
86
+ }
87
+
88
+
89
+ public class Sample : MonoBehaviour {
90
+
91
+ void Start () {
92
+
93
+ Stack<Test> tests = new Stack<Test>();
94
+ tests.Push (new Test ("1"));
95
+ tests.Push (new Test ("2"));
96
+ tests.Push (new Test ("3"));
97
+ string content = getReverseTest<Test> (tests);
98
+ Debug.Log (content);
99
+ }
100
+
101
+ string getReverseTest<Test>(Stack<Test> tests){
102
+ string content = "";
103
+ for (int i = 0; i < tests.Count; i++) {
104
+ content += tests.ElementAt (tests.Count - i - 1).s;
105
+ }
106
+ return content;
107
+ }
108
+
109
+ }
110
+ ```
111
+ ```
112
+ error CS1061: Type `Test' does not contain a definition for `s' and no extension method `s' of type `Test' could be found. Are you missing an assembly reference?
70
113
  ```

2

タイトル変更

2018/02/17 11:48

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- クラスをStackにまとめて、メソッド内でStackからクラスのプロパティにアクセスできない。
1
+ クラスをStackにまとめて、メソッド内でStackからクラスのールドにアクセスできない。
body CHANGED
File without changes

1

追記

2018/02/17 10:46

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -51,4 +51,20 @@
51
51
  }
52
52
 
53
53
  }
54
+ ```
55
+
56
+ ###追記。
57
+ sをpublicにしてみましたが、エラーメッセージが表示されます。
58
+ ```
59
+ class Test{
60
+
61
+ public string s ="";
62
+
63
+ public Test(string b){
64
+ s = b;
65
+ }
66
+ }
67
+ ```
68
+ ```
69
+ Assets/Sample.cs(33,53): error CS1061: Type `T' does not contain a definition for `s' and no extension method `s' of type `T' could be found. Are you missing an assembly reference?
54
70
  ```