1.try
{
   ...
}catch(EndOfStreamException)
{
   ...
}catch(Exception)
{
   ...
}
2. try
    {
       hello:  ...
     }catch{
        goto hello
     }

解决方案 »

  1.   

    using System;
    // it's required for reading/writing into the registry:
    using Microsoft.Win32;      
    // and for the MessageBox function:
    using System.Windows.Forms; public string Read(string KeyName)
    {
    // Opening the registry key
    RegistryKey rk = baseRegistryKey ;
    // Open a subKey as read-only
    RegistryKey sk1 = rk.OpenSubKey(subKey);
    // If the RegistrySubKey doesn't exist -> (null)
    if ( sk1 == null )
    {
    return null;
    }
    else
    {
    try 
    {
    // If the RegistryKey exists I get its value
    // or null is returned.
    return (string)sk1.GetValue(KeyName.ToUpper());
    }
    catch (Exception e)
    {
    // AAAAAAAAAAARGH, an error!
    ShowErrorMessage(e, "Reading registry " + KeyName.ToUpper());
    return null;
    }
    }
    }
    public bool Write(string KeyName, object Value)
    {
    try
    {
    // Setting
    RegistryKey rk = baseRegistryKey ;
    // I have to use CreateSubKey 
    // (create or open it if already exits), 
    // 'cause OpenSubKey open a subKey as read-only
    RegistryKey sk1 = rk.CreateSubKey(subKey);
    // Save the value
    sk1.SetValue(KeyName.ToUpper(), Value); return true;
    }
    catch (Exception e)
    {
    // AAAAAAAAAAARGH, an error!
    ShowErrorMessage(e, "Writing registry " + KeyName.ToUpper());
    return false;
    }
    }
      

  2.   

    第二个问题中涉及到几个对于Err的判断啊!能不能详细一点?
    第一个问题是说如果出现EndOfStreamException的话,不做处理,继续以后的代码(类似第二个问题);出现其它的Exception才跳转到catch语句中
      

  3.   

    而第三个问题你的代码是一般的读/写注册表的,我想问的是,c#中有没有类似于vb那样独立的子键和c#中有没有类似的独立函数?
      

  4.   

    1、
    try
    {
    ....
    }
    catch(EndOfStreamException e)
    {
      不做任何处理
    }
    catch
    {
    处理别的东西
    }
    2、
    try
        {
           label:  ...
         }catch{
            goto label
         }3、没用这个特殊的
      

  5.   

    liduke,你的回答和 qiujinwen的回答是一样的啊!第二个问题中涉及到几个对于Err的判断啊!能不能详细一点?
    第一个问题是说如果出现EndOfStreamException的话,不做处理,继续以后的代码(类似第二个问题);出现其它的Exception才跳转到catch语句中