Comparison of List in C# and vector in C++ in terms of initialization -


in c++, 1 can initialize vector as

vector<int> nums1 (100, 4); // 100 integers value 4

in additions, there like

vector<int> nums2 (nums1.begin() + 5, nums1.end() - 20);

is there similar in c# list?

you can list.

using system.collections.generic; list<int> nums1 = new list<int>(enumerable.repeat(4,100)); //100 elements each value 4 list<int> nums2 = new list<int>(nums1.skip(5).take(75)); // skip first 5 , take 75 elements 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -