CSharp examples for System:Char Unicode
Returns the value encoded in Big Endian (PPC, XDR) format.
/*/* www .j a v a 2s . com*/ * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ using System; public class Main{ public static double GetBigEndian(double value) { if (BitConverter.IsLittleEndian) { return SwapByteOrder(value); } return value; } /// <summary> /// Returns the value encoded in Big Endian (PPC, XDR) format. /// </summary> /// <param name="value">Value to encode.</param> /// <returns>Big-endian encoded value.</returns> public static long GetBigEndian(long value) { if (BitConverter.IsLittleEndian) { return SwapByteOrder(value); } return value; } /// <summary> /// Returns the value encoded in Big Endian (PPC, XDR) format. /// </summary> /// <param name="value">Value to encode.</param> /// <returns>Big-endian encoded value.</returns> public static UInt32 GetBigEndian(UInt32 value) { if (BitConverter.IsLittleEndian) { return SwapByteOrder(value); } return value; } /// <summary> /// Returns the value encoded in Big Endian (PPC, XDR) format. /// </summary> /// <param name="value">Value to encode.</param> /// <returns>Big-endian encoded value.</returns> public static UInt16 GetBigEndian(UInt16 value) { if (BitConverter.IsLittleEndian) { return SwapByteOrder(value); } return value; } #region Endian conversion helper routines /// <summary> /// Returns the value encoded in Big Endian (PPC, XDR) format. /// </summary> /// <param name="value">Value to encode.</param> /// <returns>Big-endian encoded value.</returns> public static Int32 GetBigEndian(Int32 value) { if (BitConverter.IsLittleEndian) { return SwapByteOrder(value); } return value; } }