I tend to write lots of test using boost/unit_test and I tend to generate lots of const data – for instance
#include <vector>
#include <map>
#include <string>
#include <boost/assign.hpp>
#include <boost/assign/list_of.hpp>
#include <boost/assign/std/vector.hpp>
#include <boost/assign/std/map.hpp>
namespace ba = boost::assign;
using namespace std;
const vector<int> my_vector_of_ints = ba::list_of(15)(23)(43)(22)(5)(78);
const map<int, string> my_map = ba::map_list_of(5, "abc")(7, "ddd");
etc. etc. etc.
How do I go about this stuff in C# ?
Try something like this:
Now C#’s
constdoesn’t mean the same thing as C++’sconstso you will need to realize that these instances are mutable. I have marked these fields asreadonlywhich is about as close as you are going to get.