Discussion:
コンパイルエラーの基準は
(too old to reply)
Masato
2005-01-10 03:54:22 UTC
Permalink
$B%3%s%Q%$%k%(%i!<$K4X$7$F!"5?Ld$K;W$C$?$3$H$,$"$C$?$N$GEj9F$7$^$9!#(B
$B$b$7!"@bL@$7$F$$$?$@$1$kJ}$$$i$C$7$c$$$^$7$?$i8f4j$$$7$^$9!#(B
$B5$$K$7$J$1$l$P$=$l$G$$$$$N$+$b$7$l$^$;$s$,!"!"0l1~!#(B

using System;

namespace Project1
{
struct strctPet
{
public int intPetName;

public string PetName {
get {
return PetName;
}
set {
PetName = value;
}
}

}

class Class
{
static void Main(string[] args)
{

//# $B%3%s%Q%$%kDL$k"*<B9T;~%(%i!<(B
strctPet myPet1 = new strctPet();
myPet1.PetName = "Jon";

//# $B%3%s%Q%$%k%(%i!<(B
strctPet myPet2 = new strctPet();
myPet2.intPetName = "Jon";

}
}
}

$B%(%s%H%j%]%$%s%H$G!"%m%8%C%/$H$7$F$OF1$8$3$H$7$F$$$k$N$G$9$,!"(B
$BA0<T$O%3%s%Q%$%k$,DL$j!"8e<T$O%3%s%Q%$%k$,DL$j$^$;$s!#(B

strctPet$B!!9=B$BN$N%W%m%Q%F%#<BAuIt$G!"L@$i$+$K(B string $B7?$r(B int $B7?$KBeF~$7$h$&$H(B
$B$7$F$$$k$H;W$&$N$G$9$,!#!#!#(B

$B$I$&$G$7$g$&$+!)(B



Masat.
AnswerSoft(M.Fudano)
2005-01-10 15:31:14 UTC
Permalink
$B?7G/$"$1$^$7$F$*$a$G$H$&$4$6$$$^$9!#!!(B!(^^)!$B$U!A(B
Masato$B$5$s!"$3$s$K$A$O!#(B
Post by Masato
$B%3%s%Q%$%k%(%i!<$K4X$7$F!"5?Ld$K;W$C$?$3$H$,$"$C$?$N$GEj9F$7$^$9!#(B
$B5$$K$7$J$1$l$P$=$l$G$$$$$N$+$b$7$l$^$;$s$,!"!"0l1~!#(B
$B$=$l$,!"$4<ALd$,NI$/M}2r$G$-$J$$$N$G$9$,(B(^_^;)
Post by Masato
$B$7$F$$$k$H;W$&$N$G$9$,!#!#!#(B
$B$3$NJU$,0l@#0UL#ITL@$G$9!#%$%s%G%/%5$N(B get $B%"%/%;%5!"%$%s%G%/%5$N(B set $B%"%/%;%5(B
$B!!4XO"$N$4<ALd$H;W$C$?$N$G$9$,!)(B

$B!***@h$K?J$_$^$;$s$N$G!"<h$j9g$($:!";d$,$3$s$J;v$+$J$H9M$($k%W%m%0%i%`$G$9!#!W(B

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Project1
{
public class MyClass
{
public string PutName;
public int intPutNumber;
public string strPut
{
get
{
return PutName;
}
set
{
PutName = value;
}
}
}

public class Form1 : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;

public Form1()
{
InitializeComponent();
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.Size = new System.Drawing.Size(300,300);
this.Text = "Form1";
}

[STAThread]
static void Main()
{
string Name1;
string Name2;

MyClass myPut1 = new MyClass(); // Class
myPut1.PutName = "Taro";
myPut1.intPutNumber = 10;
myPut1.strPut = "Jon"; // Put
Name1 = myPut1.strPut; // Get

MyClass myPut2 = new MyClass(); // Class
myPut2.PutName = "Akiko";
myPut2.intPutNumber = 20;
myPut2.strPut = "Tom"; // Put
Name2 = myPut2.strPut; // Get

Application.Run(new Form1());
}
}
}
Masato
2005-01-11 00:38:29 UTC
Permalink
$BJV?.$"$j$,$H$&$4$6$$$^$7$?!#(B
$B%3!<%I$^$G=q$$$F$$$?$@$$$F!"$"$j$,$H$&$4$6$$$^$9!#(B

$B;d$N<ALd$G$9$,!"0J2<$N$3$H$G$9!#(B

$B#1!%9=B$BN$N(B set$B%"%/%;%5(B $B$G!"(B int $B$J(B $BJQ?t$K(B string $B$J(B value $B$rBeF~$7$h$&$H$7$F$$$k(B
$B#2!%(Bint $B$JJQ?t$K(B stirng $B$J(B "Jon" $B$rBeF~$7$h$&$H$7$F$$$k(B

$B$G$O!"$J$<N>J}$H$b%3%s%Q%$%k%(%i!<$8$c$J$$$N$+!)$H$N5?Ld$G$9!#(B


using System;

namespace Project1
{
struct strctPet
{
public int intPetName;

public string PetName {
get {
return PetName;
}
set {
PetName = value; //----------------$B!!#1(B
}
}

}

class Class
{
static void Main(string[] args)
{

//# $B%3%s%Q%$%kDL$k"*<B9T;~%(%i!<(B
strctPet myPet1 = new strctPet();
myPet1.PetName = "Jon"; // --------------------$B!!#2(B

//# $B%3%s%Q%$%k%(%i!<(B
strctPet myPet2 = new strctPet();
myPet2.intPetName = "Jon";

}
}
}


Masato.
Tatuya
2005-01-11 01:26:25 UTC
Permalink
tatuya$B$G$9!#(B

$B:#<j85$N(BC#$B$,$J$$$N$G!"3NG'$O$7$F$$$^$;$s$,!D!D(B
Post by Masato
public string PetName {
myPet1.PetName = "Jon"; // --------------------$B!!#2(B
$B$3$l$ODL$j$^$9$h$M!)!J%3%s%Q%$%k!K(B

$B$G!"9=B$BNFbIt$G(B
Post by Masato
set {
PetName = value; //----------------$B!!#1(B
}
$B$H$J$C$F$$$k$N$G!"FbIt=[4D$7$A$c$C$F$^$;$s$+!)(B
$BK\Mh$O(B

set {
intPetName = value;
}

$B$H$J$k$Y$-$G$O$J$$$G$7$g$&$+!)!J%3%s%Q%$%k%(%i!<$K$J$j$^$9$,!K(B

$B4*0c$$$G$7$?$i$9$$$^$;$s!#(B

--
tatuya(***@hotmail.com)
Kaoru Kodaka
2005-01-11 01:35:53 UTC
Permalink
$B$+$*$/(B $B$G$9!#(B

On Tue, 11 Jan 2005 09:38:29 +0900
Post by Masato
$B#1!%9=B$BN$N(B set$B%"%/%;%5(B $B$G!"(B int $B$J(B $BJQ?t$K(B string $B$J(B value $B$rBeF~$7$h$&$H$7$F$$$k(B
$B#2!%(Bint $B$JJQ?t$K(B stirng $B$J(B "Jon" $B$rBeF~$7$h$&$H$7$F$$$k(B
$B$G$O!"$J$<N>J}$H$b%3%s%Q%$%k%(%i!<$8$c$J$$$N$+!)$H$N5?Ld$G$9!#(B
set {
PetName = value; //----------------$B!!#1(B
$B",(B intPetName $B$N(B Typo $B$G$7$g$&$+!)(B $B$A$J$_$K!"(BintPetName $B$KD>(B
$B$9$H!"$A$c$s$H%3%s%Q%$%k%(%i!<$,=P$^$9(B(Visual Studio 2003 $B$G(B
$B3NG'(B)$B!#(B
Post by Masato
$B#1!%9=B$BN$N(B set$B%"%/%;%5(B $B$G!"(B int $B$J(B $BJQ?t$K(B string $B$J(B value $B$rBeF~$7$h$&$H$7$F$$$k(B
$B$G$O!"$J$$$G$9$h$M!#(B

$B!t$b$H$N%3!<%I$N$^$^$@$H!"(BStackOverFlow $B$@$J(B...$B!#(B

---
MVP kaok = MVP.ChangeMvpCategory("for C# 2004-2005.");
kaok.Web = "http://www.antoine.st/";
Masato
2005-01-12 02:38:28 UTC
Permalink
$BJV?.$"$j$,$H$&$4$6$$$^$9!#(B
Post by Kaoru Kodaka
Post by Masato
set {
PetName = value; //----------------$B!!#1(B
$B",(B intPetName $B$N(B Typo $B$G$7$g$&$+!)(B $B$A$J$_$K!"(BintPetName $B$KD>(B
$B$9$H!"$A$c$s$H%3%s%Q%$%k%(%i!<$,=P$^$9(B(Visual Studio 2003 $B$G(B
$B$A$J$_$KKM$N3+H/4D6-$O!"(BBorland C#Builder Personal $B$G$9!#(B
Post by Kaoru Kodaka
Post by Masato
$B#1!%9=B$BN$N(B set$B%"%/%;%5(B $B$G!"(B int $B$J(B $BJQ?t$K(B string $B$J(B value $B$rBeF~$7$h$&$H$7$F$$$k(B
$B$G$O!"$J$$$G$9$h$M!#(B
$B%3!<%G%#%s%0J}K!$H$7$F$O!"8m$C$F$$$k$N$O>5CN$@$C$?$N$G$9$,(B
$B<B83$7$F$?$N$G$9!#(B

set {
PetName = value
}

$B$O!"(B int $B7?$N(B PetName $B$K(B string $B7?$N(B value $B$rBeF~$7$F$$$k$o$1$G$O$J$$!#(B
$B$H$$$&$3$H$G$7$g$&$+!)(B

$B!&!&!&$H$$$&$3$H$O!"%3%s%Q%$%i$O%]%$%s%?$r;H$C$F$k$+$i0EL[$N%-%c%9%H$,5v$5$l$F$$$k$H(B
$BM}2r$9$Y$-$G$7$g$&$+!)(B
.NET $B$C$F$=$&$$$&;EAH$_$G$7$?$C$1!&!&!&!J>P!K(B

$B$J$s$+$\$/!"$9$4$$4*0c$$$7$F$$$k$h$&$J!&!&(B



$B$*A{$,$;$7$F$9$_$^$;$s!#(B
AnswerSoft(M.Fudano)
2005-01-11 02:23:06 UTC
Permalink
Masato$B$5$s!"$3$s$K$A$O!!(B!(^^)!$B$U!A$G$9!#(B
Post by Masato
$B#1!%9=B$BN$N(B set$B%"%/%;%5(B $B$G!"(B int $B$J(B $BJQ?t$K(B string $B$J(B value $B$rBeF~$7$h$&$H$7$F$$$k(B
$B#2!%(Bint $B$JJQ?t$K(B stirng $B$J(B "Jon" $B$rBeF~$7$h$&$H$7$F$$$k(B
$B$G$O!"$J$<N>J}$H$b%3%s%Q%$%k%(%i!<$8$c$J$$$N$+!)$H$N5?Ld$G$9!#(B
$B;d$,!";W$&$K!"2<5-%3!<%G%#%s%0$KL5M}$,$"$k$N$G$O$H9M$($^$9!#(B
$B!J%/%i%9$G$OL5$$$N$GJQ?t0J30$O$A$g$C$H$$$1$^$;$s!K(B

struct strctPet
Post by Masato
{
public int intPetName;
public string PetName {
get {
return PetName;
}
set {
PetName = value; //----------------$B!!#1(B
}
}
$B$3$NJU$G!"@5$7$/9=B$BN!J%9%H%i%/%A%c!K$,@.N)$7$F$$$l$PNI$$$N$G$9$,!)(B

Masato$B$5$s$N%3!<%G%#%s%0$7$?$$FbMF$O!"!V%$%s%G%/%5$N(BGet$B%"%/%;%5!"(BSetGet$B%"%/%;%5(B
$B$G9=B$BN$r;H$&J}K!!W$G$"$k$H2r<a$7$^$7$?!#$G$"$l$P!";d$N>l9g$O$I$&$9$k$+$NNc$G$9!#(B
$B!J9=B$BN$OBeF~$G$-$k$H8@$&;v$,%]%$%s%H$G$9!K(B

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices; // Win32$B!"(B $B%9%H%i%/%A%c!<(B

[StructLayout(LayoutKind.Sequential)]
public struct MYDATA
{
public int intPutNumber; $B!!(B// $BHV9f(B
public string PutName; $B!!(B// $BL>A0(B
}

namespace Project1
{
public class MyClass
{
public MYDATA Data;

public MYDATA DataPut
{
get
{
return Data;
}
set
{
Data = value;
}
}
}

public class Form1 : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;

public Form1()
{
InitializeComponent();
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.Size = new System.Drawing.Size(300,300);
this.Text = "Form1";
}

[STAThread]
static void Main()
{
MYDATA Data1;
MYDATA Data2;

Data1.PutName = "Jon";
Data1.intPutNumber = 10;
MyClass myPut1 = new MyClass(); // Class
myPut1.Data.PutName = "Taro";
myPut1.Data.intPutNumber = 20;
myPut1.DataPut = Data1; // Put
Data1 = myPut1.DataPut; // Get

Data2.PutName = "Tom";
Data2.intPutNumber = 30;
MyClass myPut2 = new MyClass(); // Class
myPut2.Data.PutName = "Akiko";
myPut2.Data.intPutNumber = 40;
myPut2.DataPut = Data2; // Put
Data2 = myPut2.DataPut; // Get

Application.Run(new Form1());
}
}
}
Masato
2005-01-12 02:41:58 UTC
Permalink
Takuya $BMM$N2sEz$G$o$+$j$^$7$?!#(B
$B;d$N%3!<%G%#%s%0%_%9$G$7$?!#(B

$B?=$7Lu$J$$$G$9!#(B
Post by Tatuya
Post by Masato
set {
PetName = value; //----------------$B!!#1(B
}
$B$H$J$C$F$$$k$N$G!"FbIt=[4D$7$A$c$C$F$^$;$s$+!)(B
$BK\Mh$O(B
set {
intPetName = value;
}
$B$H$J$k$Y$-$G$O$J$$$G$7$g$&$+!)!J%3%s%Q%$%k%(%i!<$K$J$j$^$9$,!K(B
$B"-(B
$B$=$N$H$*$j$G$9!#!JCQ!K(B
Zhou Peng
2005-02-13 10:01:58 UTC
Permalink
On Mon, 10 Jan 2005 12:54:22 +0900, Masato <***@yahoo.co.jp> wrote:

こんばんは、コメントを見ていただきますか?
Post by Masato
struct strctPet
{
public int intPetName;
public string PetName {
get {
return PetName;   ------->return intPetNameか?(return
intPetName.ToString()?)
}
set {
PetName = value;   ------->intPetName = value;か?
(intPetName = Convert(value,Int32)か?Convert関数のパラメー
ター をよく覚えていないけど
}
}
}
と思っていますが、もうちょっと詳しいエラー情報を書いていないから、どんな問
題が出されたのは分からないです。
Post by Masato
コンパイルエラーに関して、疑問に思ったことがあったので投稿します。
もし、説明していただける方いらっしゃいましたら御願いします。
気にしなければそれでいいのかもしれませんが、、一応。
using System;
namespace Project1
{
struct strctPet
{
public int intPetName;
public string PetName {
get {
return PetName;
}
set {
PetName = value;
}
}
}
class Class
{
static void Main(string[] args)
{
//# コンパイル通る→実行時エラー
strctPet myPet1 = new strctPet();
myPet1.PetName = "Jon";
//# コンパイルエラー
strctPet myPet2 = new strctPet();
myPet2.intPetName = "Jon";
}
}
}
エントリポイントで、ロジックとしては同じことしているのですが、
前者はコンパイルが通り、後者はコンパイルが通りません。
strctPet 構造体のプロパティ実装部で、明らかに string 型を int 型に代入し
ようと
していると思うのですが。。。
どうでしょうか?
Masat.
--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Loading...