Пример #1
0
        public static LocalDeclarationStatementSyntax LocalVairableDeclaration(
            this TypeSyntax type,
            string name,
            ExpressionSyntax value = null)
        {
            var declarator = SF.VariableDeclarator(SF.Identifier(name));

            if (value != null)
            {
                declarator = declarator.WithInitializer(SF.EqualsValueClause(value));
            }

            var delaration = SF.LocalDeclarationStatement(
                SF.VariableDeclaration(type)
                .WithVariables(SF.SingletonSeparatedList(declarator)));

            return(delaration);
        }