Total Page Preview: 000000006026
Explain difference between Convert.ToString() method and .ToString() method in C# in English and Hindi
Differnce between Convert.ToString() method and .ToString() method in C# in English
In summary, the Convert.ToString() method is a static method that can handle null values, can be used to specify a format provider, and can handle any data type. On the other hand, the .ToString() method is an instance method that cannot handle null values, cannot specify a format provider, and can only be used on objects that inherit from the Object class.
Differnce between Convert.ToString() method and .ToString() method in C# in Hindi
Dono method C# me string ko convert karne ke liye use kiye jate hai, lekin kuch antar hai:
1-Convert.ToString() method:
-
Ye method System.Convert class ke ek static method hai.
-
Is method ka upyog anya data types ko string me convert karne ke liye kiya jata hai.
-
Is method ko use karne ke liye nullable operator ki zaroorat nahi hoti hai, kyunki ye method null value ko bhi sahi tarike se handle karta hai.
-
Agar is method ke andar null value diya jaye to ye "null" string ko return karega.
.2-ToString() method:
-
Ye method System.Object class ke ek instance method hai.
-
Is method ka upyog sirf wahi data types ke liye kiya jata hai jo System.Object class se inherit kiye gaye hote hai.
-
Is method ko use karne ke liye nullable operator ki zaroorat hoti hai, kyunki null value ko handle karne ke liye null conditional operator ka upyog kiya jata hai.
-
Agar is method ke andar null value diya jaye to ye null reference exception throw karega.
Tabular form me dono method ke antar is prakar hai:
Thank You
About Author
Brijesh Kumar
Database Developer
I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL
Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall
and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com