PDA

View Full Version : معایب stringbuilder



behrad110
دوشنبه 17 بهمن 1390, 19:47 عصر
از مزایا stringbuilder خیلی صحبت شده و فکر میکنم اکثرا برتری های stringbuilder رو میدونن امامعایبی هم داره که فکر میکنم یکی اش استفاده در برنامه های multi thread هست که ظاهرا اختلالاتی ایجاد میکنه و میگن thread safe نیست . در این مورد و معایب دیگه اگه دوستان مطلب جدیدی دارن .فکر میکنم برای بچه ها مفید باشه .
در واقع سوال اصلی من این هست که در چه مواردی بهتره از stringbuilder استفاده نکنیم
ممنون

behrad110
سه شنبه 18 بهمن 1390, 10:47 صبح
کسی در مورد معایب string builder مطلبی نداره؟ فکر میکنم مفید باشه. بالاخره جا هایی هم وجود داره که string builder مفید نیست

behrad110
پنج شنبه 20 بهمن 1390, 18:34 عصر
The performance of a concatenation operation for a String or StringBuilder object depends on the frequency of memory allocations. A String concatenation operation always allocates memory, whereas a StringBuilder concatenation operation allocates memory only if the StringBuilder object buffer is too small to accommodate the new data. Use the String class if you are concatenating a fixed number of String objects. In that case, the compiler may even combine individual concatenation operations into a single operation. Use a StringBuilder object if you are concatenating an arbitrary number of strings; for example, if you're using a loop to concatenate a random number of strings of user input.
این از msdn آوردم اما کافی نیست منتظر نظرات تکمیلی دوستان هستم