別にカンマ区切りじゃなくていいんやけど。
class Test { static void Main (string [] args) { var s = "e0,106,aa,12"; var regex = new System.Text.RegularExpressions.Regex ("\\b(\\d+)\\b"); var matches = regex.Matches (s); var numbers = matches .OfType<System.Text.RegularExpressions.Match> () .Select (match => Convert.ToInt32 (match.Groups [1].Value)) .ToArray (); foreach (var number in numbers) Console.WriteLine ("{0}:{1}", number, number.GetType ()); } }
Visual Studio 2008 で XAML ファイルを開くと VS 自体が異常終了するようになってしまった。以下イベントログ。
ソース: .NET Runtime
種類: エラー
イベント ID: 1023
説明:
.NET Runtime version 2.0.50727.3082 - 致命的な実行エンジン エラーが発生しました (7A2E1132) (0)
「VS2008 crashes with "Fatal Execution Engine Error"」に、以下の投稿があった。
Thanks to Paul I found a very strange workaround (I verified it a few times)If I do that before I start the debugger VS will not crash.
- open the solution
- unload the project (context menu)
- edit the csproj (context menu), don't make any changes
- reload the project (contect menu)
つまり
嘘みたいだが、これで本当に解決。
System.Windows.Input.InputMethod の添付プロパティの挙動がよくわかんない。
<Window x:Class="WpfSample.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="テキストボックスで IME の ON/OFF を指定する" SizeToContent="Height" Width="300"> <Window.Resources> <Style TargetType="TextBox"> <Setter Property="Margin" Value="5"/> </Style> <Style TargetType="Label"> <Setter Property="VerticalContentAlignment" Value="Center"/> </Style> </Window.Resources> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Label Content="IME ON:" Grid.Row="0"/> <TextBox InputMethod.PreferredImeState="On" Grid.Column="1" Grid.Row="0" Text="On のはず"/> <Label Content="IME OFF:" Grid.Row="1"/> <TextBox InputMethod.PreferredImeState="Off" Grid.Column="1" Grid.Row="1" Text="Off のはず"/> </Grid> </Window>
とりあえず、これで意図したとおりにうごくっぽい。