質問編集履歴

2

修正

2015/10/26 10:06

投稿

fender0131
fender0131

スコア121

test CHANGED
File without changes
test CHANGED
@@ -103,3 +103,131 @@
103
103
  }
104
104
 
105
105
  }
106
+
107
+
108
+
109
+
110
+
111
+ ※ 追記1
112
+
113
+
114
+
115
+ 試行錯誤した結果、クラスを引数として渡せたと思うのですが、この方法はあっていますでしょうか?
116
+
117
+ 他に最適な方法などありますでしょうか?
118
+
119
+ お手数おかけして申し訳ございませんが、再度ご教授願えませんでしょうか?
120
+
121
+
122
+
123
+
124
+
125
+ using System;
126
+
127
+ using System.Collections.Generic;
128
+
129
+ using System.ComponentModel;
130
+
131
+ using System.Data;
132
+
133
+ using System.Drawing;
134
+
135
+ using System.Linq;
136
+
137
+ using System.Text;
138
+
139
+ using System.Threading.Tasks;
140
+
141
+ using System.Windows.Forms;
142
+
143
+
144
+
145
+ namespace WindowsFormsApplication4
146
+
147
+ {
148
+
149
+ class hensuu
150
+
151
+ {
152
+
153
+ public double sum;
154
+
155
+
156
+
157
+ public double a1;
158
+
159
+ public int b1;
160
+
161
+ public int c1;
162
+
163
+ public int d1;
164
+
165
+ public int e1;
166
+
167
+ public int f1;
168
+
169
+ public double g1;
170
+
171
+ // ... int z = 26
172
+
173
+ }
174
+
175
+
176
+
177
+ public partial class Form1 : Form
178
+
179
+ {
180
+
181
+ public Form1()
182
+
183
+ {
184
+
185
+ InitializeComponent();
186
+
187
+ }
188
+
189
+
190
+
191
+ public void Form1_Load(object sender, EventArgs e)
192
+
193
+ {
194
+
195
+ hensuu h = new hensuu();
196
+
197
+
198
+
199
+ h.a1 = 1.5;
200
+
201
+ h.b1 = 2;
202
+
203
+ h.c1 = 3;
204
+
205
+ h.d1 = 4;
206
+
207
+ h.e1 = 5;
208
+
209
+ h.f1 = 6;
210
+
211
+ h.g1 = 7.5;
212
+
213
+
214
+
215
+ math(ref h);
216
+
217
+
218
+
219
+ }
220
+
221
+
222
+
223
+ private void math (ref hensuu h)
224
+
225
+ {
226
+
227
+ h.sum = h.a1 + h.b1 + h.c1 + h.d1 + h.e1 + h.f1 + h.g1 /* ・・・ + z1 */;
228
+
229
+ }
230
+
231
+ }
232
+
233
+ }

1

修正

2015/10/26 10:06

投稿

fender0131
fender0131

スコア121

test CHANGED
File without changes
test CHANGED
@@ -62,7 +62,11 @@
62
62
 
63
63
 
64
64
 
65
+ double sum = 0;
66
+
67
+
68
+
65
- int a1 = 1;
69
+ float a1 = 1.5;
66
70
 
67
71
  int b1 = 2;
68
72
 
@@ -74,13 +78,9 @@
74
78
 
75
79
  int f1 = 6;
76
80
 
77
- int g1 = 7;
81
+ float g1 = 7.5;
78
82
 
79
83
  // ... int z = 26
80
-
81
-
82
-
83
- int sum = 0;
84
84
 
85
85
 
86
86
 
@@ -92,7 +92,7 @@
92
92
 
93
93
 
94
94
 
95
- private void math (ref int sum, int a1, int b1, int c1, int d1, int e1, int f1, int g1 /* ... int z */)
95
+ private void math (ref double sum, float a1, int b1, int c1, int d1, int e1, int f1, float g1 /* ... int z */)
96
96
 
97
97
  {
98
98