Workflow Foundation 问题中的字符串切换 [英] Switch of string in Workflow Foundation issue

查看:20
本文介绍了Workflow Foundation 问题中的字符串切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 WF4 中遇到了一个非常奇怪的问题:当我使用 Switch 活动并决定字符串变量的值时,WF 以某种方式将 Switch 的参数视为字符串,而不是变量的名称.因此我得到了错误的结果.复制步骤:

I've encountered a very weird problem with WF4: when I use Switch activity and make the decision on the value of a string variable somehow WF treats argument to the Switch as a string, not the name of the variable. And consequently I get incorrect results. Steps to repro:


- create new WF
- add Sequence
- add Switch of String to the Sequence
- add a new string variable named, for instance, [testText] and set its default value to "test"
- set argument of the switch to testText
- create a case in the switch for "test" string and show msgbox on it
- create another case, let it be default case which shows another msgbox with "default" text
- run

突然这里我们得到一个带有默认"文本的消息框,而不是 testText 案例的文本

And suddenly here we get a message box with "default" text, not the one for the testText case

推荐答案

您需要使用 test 的值而不带引号.案例包含文字值,而不是表达式.是的,我也觉得这很令人困惑.

You need to use the value of test without the quotes. The cases contain a literal value, not an expression. And yes I find this confusing as well.

这篇关于Workflow Foundation 问题中的字符串切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆