質問編集履歴
4
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -223,3 +223,13 @@
|
|
223
223
|
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?
|
224
224
|
|
225
225
|
```
|
226
|
+
|
227
|
+
ちなみに下記は通ります。
|
228
|
+
|
229
|
+
```
|
230
|
+
|
231
|
+
string ss = new Test ("1").s;
|
232
|
+
|
233
|
+
Debug.Log (ss); //1
|
234
|
+
|
235
|
+
```
|
3
追記②
test
CHANGED
File without changes
|
test
CHANGED
@@ -137,3 +137,89 @@
|
|
137
137
|
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?
|
138
138
|
|
139
139
|
```
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
###追記②
|
144
|
+
|
145
|
+
```
|
146
|
+
|
147
|
+
using System.Collections;
|
148
|
+
|
149
|
+
using System.Collections.Generic;
|
150
|
+
|
151
|
+
using UnityEngine;
|
152
|
+
|
153
|
+
using System.Linq;
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
class Test{
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
public string s ="";
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
public Test(string b){
|
166
|
+
|
167
|
+
s = b;
|
168
|
+
|
169
|
+
}
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
public class Sample : MonoBehaviour {
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
void Start () {
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
Stack<Test> tests = new Stack<Test>();
|
186
|
+
|
187
|
+
tests.Push (new Test ("1"));
|
188
|
+
|
189
|
+
tests.Push (new Test ("2"));
|
190
|
+
|
191
|
+
tests.Push (new Test ("3"));
|
192
|
+
|
193
|
+
string content = getReverseTest<Test> (tests);
|
194
|
+
|
195
|
+
Debug.Log (content);
|
196
|
+
|
197
|
+
}
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
string getReverseTest<Test>(Stack<Test> tests){
|
202
|
+
|
203
|
+
string content = "";
|
204
|
+
|
205
|
+
for (int i = 0; i < tests.Count; i++) {
|
206
|
+
|
207
|
+
content += tests.ElementAt (tests.Count - i - 1).s;
|
208
|
+
|
209
|
+
}
|
210
|
+
|
211
|
+
return content;
|
212
|
+
|
213
|
+
}
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
}
|
218
|
+
|
219
|
+
```
|
220
|
+
|
221
|
+
```
|
222
|
+
|
223
|
+
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?
|
224
|
+
|
225
|
+
```
|
2
タイトル変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
クラスをStackにまとめて、メソッド内でStackからクラスの
|
1
|
+
クラスをStackにまとめて、メソッド内でStackからクラスのフィールドにアクセスできない。
|
test
CHANGED
File without changes
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -105,3 +105,35 @@
|
|
105
105
|
}
|
106
106
|
|
107
107
|
```
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
###追記。
|
112
|
+
|
113
|
+
sをpublicにしてみましたが、エラーメッセージが表示されます。
|
114
|
+
|
115
|
+
```
|
116
|
+
|
117
|
+
class Test{
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
public string s ="";
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
public Test(string b){
|
126
|
+
|
127
|
+
s = b;
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
}
|
132
|
+
|
133
|
+
```
|
134
|
+
|
135
|
+
```
|
136
|
+
|
137
|
+
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?
|
138
|
+
|
139
|
+
```
|