Is it possible to flip a string vertically in C#, e.g. given
string s= "123456";
The result is:
I need to assign the resulting string to a string type in C#.
The reason I need the function is that I have a chart that needs to be rotated to meet requirements. Therefore, any te开发者_JS百科xts within the chart have to be rotated.
You mean you want to render it upside down.
Strings do not have an "orientation" in and of themselves - this is entirely something to do with rendering them for display.
You can use the classes in the System.Drawing
to create an image with each character displayed upside down (an image transform with RotateFlipType
for example), though whether this is a good option entirely depends on what technology you are using and how you want to display and use the text.
If you're using WPF or Silverlight, this is fairly easy. Just apply a ScaleTransform with a scale of (1.0, -1.0)
to the rendered text.
You can use transform in WPF and rotate it in any angle
<RotateTransform CenterX="0" CenterY="0" Angle="180" />
UPD: sorry, i've probably misunderstood your question. You can use a VisualBrush to do this.
精彩评论