Struct
Solidityपरिभाषा
Struct एक custom data type है जो multiple related variables को group करता है। Structs complex data को organize करने के लिए use होते हैं। Struct members different types के हो सकते हैं। Structs को mappings और arrays में use किया जा सकता है।
English version
Struct is a custom data type that groups multiple related variables. Structs are used to organize complex data. Struct members can be of different types. Structs can be used in mappings and arrays.
Code Example
struct User {
string name;
uint256 balance;
bool isActive;
uint256 joinedAt;
}
// Mapping de structs
mapping(address => User) public users;
// Créer un struct
function createUser(string memory name) public {
users[msg.sender] = User({
name: name,
balance: 0,
isActive: true,
joinedAt: block.timestamp
});
}संबंधित पेज
Solingo पर इस concept को practice करें
Struct को interactive exercises और integrated IDE के साथ master करें।
मुफ्त में शुरू करें