Dictionary ์ generic class ๋ฅผ ๋ฃ๊ณ ์ถ์๋ฐย
์) Dictionary<string, Car<T>>ย
์ด๋ฐ์์ผ๋ก ํ๊ณ ์ถ์๋ฐ์ย T ๋ฅผ define ์ํ๊ณ ๋ฃ์์์๋๋ฐฉ๋ฒ์์๊น์?
์)
public class CarAsset
{
ย ย public Dictionary<int, ???> carDic;
ย ย carDic[1] = car<blue>;
ย ย carDic[2] = car<Red>;
}
public class carAsset<T> ์ด๋ ๊ฒ ์์ฐ๊ณ ย public class CarAsset ์ด์ํ์์ย dictionary์ define ์๋๊ฑฐ๋ฅผ ๋ฃ์์์๋๋ฐฉ๋ฒ์ด์์๊น์
์ ๊ฐ ์๊ฐํด๋ณธ๊ฑดย ย public Dictionary<int, object> carDic; ์ธ๋ฐ์ ์ฌ๊ธฐ์ where ์จ์ car<T> ํ๋ ๋ฐฉ๋ฒ์ธ๋ฐ using.systemLinqํ๋ฉด ๋๋ค๋๋ฐ
์ด๋ฌ๋ฉด ๋ T๋ฅผ defineํด์ผ๋์ ๋งํ๋ค์
์ข์ ๋ฐฉ๋ฒ์ด์์๊น์? ๋ฏธ๋ฆฌ๊ฐ์ฌ๋๋ฆด๊ผ์ํ๋๋ค
https://stackoverflow.com/questions/654752/can-i-create-a-dictionary-of-generic-types/654851#654851
ํด๋์ค๋ก ํ๋ฒ ๋ฌถ์ด์ ํ๋ณํ ํ๋๋กํ๋ ๋๋ฒ์งธ ๋ต๋ณ์ด ์ ์ผ ๊ด์ฐฎ์๋ฏ?
๊ทธ๋ฌ๋ค์ ใณใณใณ ๊ณ ๋ง์์ ํ๋