C# How to replace Microsoft’s Smart Quotes with straight quotation marks?

A more extensive listing of problematic word characters if (buffer.IndexOf(‘\u2013’) > -1) buffer = buffer.Replace(‘\u2013’, ‘-‘); if (buffer.IndexOf(‘\u2014’) > -1) buffer = buffer.Replace(‘\u2014’, ‘-‘); if (buffer.IndexOf(‘\u2015’) > -1) buffer = buffer.Replace(‘\u2015’, ‘-‘); if (buffer.IndexOf(‘\u2017’) > -1) buffer = buffer.Replace(‘\u2017’, ‘_’); if (buffer.IndexOf(‘\u2018’) > -1) buffer = buffer.Replace(‘\u2018’, ‘\”); if (buffer.IndexOf(‘\u2019’) > -1) buffer = buffer.Replace(‘\u2019’, … Read more

How to reduce the capacity of a std::vector

With C++11, you can call the member function shrink_to_fit(). The draft standard section 23.2.6.2 says: shrink_to_fit is a non-binding request to reduce capacity() to size(). [Note: The request is non-binding to allow latitude for implementation-specific optimizations. —end note]

How can I convert a string length to a pixel unit?

Without using of a control or form: using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(new Bitmap(1, 1))) { SizeF size = graphics.MeasureString(“Hello there”, new Font(“Segoe UI”, 11, FontStyle.Regular, GraphicsUnit.Point)); } Or in VB.Net: Using graphics As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(New Bitmap(1, 1)) Dim size As SizeF = graphics.MeasureString(“Hello there”, New Font(“Segoe UI”, 11, FontStyle.Regular, GraphicsUnit.Point)) End Using

Classes in razor engine template

Yes, this is completely possible. Use the @functions keyword: @functions { public class MyClass { public MyClass() { Three = new List<string>(); } public string One { get; set; } public int Two { get; set; } public List<string> Three { get; set; } } }