当前位置:网站首页>How to determine whether T is a value type in a generic type or a reference class- How to determine whether T is a value type or reference class in generic?
How to determine whether T is a value type in a generic type or a reference class- How to determine whether T is a value type or reference class in generic?
2022-06-13 00:36:00 【Technology feast】
problem :
I have a generic method behavior of which depends on T is reference type or value type. I have a generic method whose behavior depends on T Is it a reference type or a value type .It looks so: It looks like this :
T SomeGenericMethod <T> (T obj){ if (T is class) //What condition I must write in the brackets? //to do one stuff else //if T is a value type like struct, int, enum and etc. //to do another stuff}
I can't duplicate this method like: I can't copy this method like this :
T SomeGenericMethod <T> (T obj) where T : class{ //Do one stuff}T SomeGenericMethod <T> (T obj) where T : struct{ //Do another stuff}
because their signatures are equal. Because their signatures are equal .Can anyone help me? Who can help me ?
Solution :
Reference resources : https://stackoom.com/en/question/Vnyi边栏推荐
- ik分词器的安装
- 电商员工离职后将产品价格改为1折出售,已被刑拘
- Is the brokerage account in qiniu business school safe? Is the account opening rate low
- Target recognition gadget
- Paper reading and sharing
- Delphi2009 connecting Oracle11g
- Installation of IK word breaker
- Kali system -- dnsmap for DNS collection and analysis
- Go implements concurrent non blocking caching
- Easyexcel read excel simple demo
猜你喜欢
Some basic design knowledge
antdPro - ProTable 实现两个选择框联动效果
Stm32f4 development of DMA transmission to GPIO port
Using com0com/com2tcp to realize TCP to serial port (win10)
Arduino controls tb6600 driver +42 stepper motor
[MRCTF2020]Ez_bypass --BUUCTF
Transaction creation of btcd transaction process (I)
MAYA建模六
In / out / inout details of MySQL stored procedures
MySQL locates the position of the character in the string String substitution
随机推荐
新增博客地址
What are the levels of safety accidents
2022施工員-設備方向-通用基礎(施工員)操作證考試題及模擬考試
Stm32f4 development of DMA transmission to GPIO port
Binary search the specified number of numbers in the array binary advanced
[LeetCode]3. The longest substring without duplicate characters forty
BUUCTF之BabyUpload[GXYCTF2019]
[GYCTF2020]Ezsqli --BUUCTF
[MRCTF2020]Ez_ bypass --BUUCTF
After so long use, CSDN has finally opened a blog
Buuctf babyupload[gxyctf2019]
Solution to the problem of closing the watchdog of STM32 in the sleep mode (stop/standby)
哲学和文学的区别
[gxyctf2019] no dolls -- detailed explanation
6.824 Lab 2: Raft
睡前小故事之MySQL起源
Set sail
Five mock technologies of go
MySQL lpad() and rpad() concatenate string functions with specified length
电商员工离职后将产品价格改为1折出售,已被刑拘